Last updated on November 18, 2018
Nikola is one of the most popular static website generators. It compiles source files into final publishable webpages offline and then uploads those files to a web host. Compared to dynamic websites such as those powered by PHP or Ruby on Rails, static websites offer better security and faster page loading.
Nikola provides some utilities to ease the deployment procedure (i.e., uploading compiled webpages), especially for deploying as GitHub pages. Unfortunately, Nikola does not (and its team does not plan to) provide a direct way to deploy the compiled webpages to a git repository that is different from the one that hosts the source files. This is often useful when you want to hide the source files in a private git repository and leave the git repository that hosts the compiled webpages public. Luckily, Nikola provides customizable deploying commands. Assuming output
is the directory where the compiled webpages are located, change the value of DEPLOY_COMMANDS
using the following in conf.py
(replace me@example.com
with your email address, https://xuhdev@github.com/xuhdev/xuhdev.github.io.git
with your designated git repository on GitHub/GitLab/BitBucket/etc., and master
with your designated branch):
DEPLOY_COMMANDS = {
'default': [
"cd output && git init && git config user.email me@example.com && touch .nojekyll && git add .",
"cd output && git commit -a -m 'Nikola'",
"cd output && git push -f https://xuhdev@github.com/xuhdev/xuhdev.github.io.git master",
]
}
Now running nikola deploy
should deploy the compiled webpages to your designated git repository and branch.