Deploying the Site
User Guide → Deploying the SiteA site generated by MarkBind can be deployed by simply uploading the generated files to any Web server. In addition, MarkBind provides several convenient deployment options.
baseUrl
property of the site.json
file to match the deploy location.markbind serve
command to stage the site locally and confirm the contents are as expected.markbind build
command to generate the site from source files. That command puts the generated site files in a directory named _site
(you can change the output directory using parameters supplied to the command).Steps for deploying multiple MarkBind sites:
site.json
files. Ensure that the baseUrl
property of each site.json
file matches its deploy location.markbind serve -s <file>
command to stage each site locally and confirm the contents are as expected.markbind build -s <file>
command to generate the site from source files.MarkBind can easily deploy a site to Github pages if the project root directory is also a GitHub repo.
markbind deploy
commandRunning the markbind deploy
command will deploy the most recent build of your site to the gh-pages
branch of the repo origin
and will be available.
Then, navigate to the Settings > Pages
section on GitHub for that repository and set the source to the root of the gh-pages
branch. You can read this source on Github Pages for more details.
Your site will be online at http://<username|org>.github.io/<repo>
(e.g., http://se-edu.github.io/se-book).
If you are deploying the site to GitHub pages, the baseUrl
setting in the site.json
should be set to the "/<repositoryName>"
for the links in the deployed site to work correctly.
Example If you are using Github Pages to host your deployed website at repo myorg/myproduct
(i.e., the website is published at https://myorg.github.io/myproduct
), then your baseUrl
should be "/myproduct"
.
You can override the default deployment settings (e.g., repo/branch to deploy) in the site.json
's deploy
section:
markbind deploy
does not generate the static site from your source; it simply deploys the files that are already in the _site
directory. You need to run markbind build
first if you want to generate the site before deploying.
You can setup CI Platforms to automatically build and deploy your site on GitHub Pages every time your GitHub repo is updated.
You can setup to automatically build and deploy your site on their platform every time your GitHub repo is updated.
Here are the steps to set up Netlify:
Go to https://app.netlify.com/ and sign up
Next go to https://app.netlify.com/account/sites and select New site from Git
Select your git provider
Select your MarkBind site repository
Update the build settings as follows and hit Deploy site
:
Build Command
: npm i markbind-cli -g && markbind build --baseUrl
Publish directory
: _site
Show advanced
: Add a new variable with the key as NODE_VERSION
and the value as 12
or higherNow your site will be deployed on Netlify at the given address specified after deployment. It will be updated automatically when the default branch of your repo is updated.
If you are hosting your MarkBind project on Github, you can setup in order to automatically build and deploy the modified MarkBind site based on the changes in the PR.
By following the steps to deploy to Netlify in the previous section, you would automatically be able to preview PRs.
You can preview the updated site at the bottom of the pull request by clicking on details
link in the PR:
For more information on previewing PRs with Netlify, you may refer to Netlify's docs.
You may also preview PRs using Surge, which is an NPM package that does static web publishing. Here are the steps to do so:
First install Surge using by typing npm install --global surge
on your terminal.
Next, type surge
in the terminal. You should see the following prompt:
Proceed to create a Surge account. After you have set up your account, you should see the following screen:
Hit CTRL-C
on your keyboard to quit the current running Surge process.
The rest of the Surge setup is unnecessary for the purposes of setting up PR previews. You may still proceed with the rest of the setup such as setting the project directory and the domain name, if you wish to.
Next, type surge token
to generate your surge token.
In the repo of your MarkBind site, create a new secret by going to "Settings"->"Secrets" and naming it as SURGE_TOKEN
and setting its value to the value of the generated surge token.
Commit and push the following 2 files into your markbind site repo, in the directory <PROJECT_ROOT>/.github/workflows/
.
Finally, you may open a PR to the repo of your MarkBind site. If everything is configured correctly, after a few minutes, you should be able to see a github-actions bot
automatically commenting on the PR with a link to preview the updated MarkBind site.
For more information on Surge, you may refer to Surge's docs.