Greetings! GitHub pages provide a free platform where you may host your static websites and that too with free SSL. If you have a pelican blog, then you may consider GitHub pages to host it. Therefore, in this post, find out how to publish your pelican blog on GitHub pages for free in just 5 minutes.
This is part 3 of 3 in my trilogy of Pelican Tutorials. It is recommended that you read the previous part 1 and part 2 for better understanding of this current part 3.
- A pelican blog
- A GitHub account
- *nix based machine (GNU/Linux, Mac, etc)
- Git, Python, Pelican, and gh-pages Basics
I am using the following in this tutorial
Ubuntu: v20.04 Python: v3.8.2 pip: v20.2 ghp-import: v0.5.5 git: v2.25.1 pelican: v4.2.0
3. Initial Step
- Change to pelican blog directory $cd myblog/
- Activate python virtualenv (if you are using) $workon myblog/
4. Initialize your blog as a git repository
5. Commit all files in master branch except output directory
echo "output/" >> .gitignore git add -A git commit -m "Initialize Pelican Blog Setup"
6. Locally set up your gh-pages branch
We’ll use ghp-import for this. This tool is very convenient while using pelican blog to publish on gh-pages.
pip install ghp-import
ghp-import ./output/ -m "Initial Setup"
Syntax is: ghp-import /path/to/output/directory/of/pelican/blog -m “Commit Message”
Note: ghp-import will itself create your gh-pages branch and a new commit in it.
7. Create an empty GitHub repository
Go to you GitHub Account and create an empty git repository with following specs:
Name: Same as your local blog directory; e.i: myblog Description: As you find best Gitignore: None; Licence: None; Initialize with README: No
Once it is created. You will get its URL like:
firstname.lastname@example.org:username/repo_name.git (For SSL option)
https://github.com/username/repo_name.git (For HTTPS option)
Copy this URL. It will be required to set your git origin on local machine.
8. Set git remote
git remote add origin email@example.com:geekyshacklebolt/blog.git
Syntax is: git remote add remote_name remote_URL
9. Push your gh-pages branch to GitHub
Checkout to gh-pages branch that is already created above using ghp-import.
git checkout gh-pages
Push this branch to your remote
git push origin gh-pages
10. Set gh-pages as default branch
If you have only one branch on GitHub in a repository, then that will be the default branch for that repo automatically. But If you want to push your master branch as well on GitHub. Then be sure that you make your gh-pages branch as default.
You can do that by accessing Your GitHub Account -> Repository -> Settings -> Branches -> Default Branch
11. View your blog
Once your gh-pages is created as default branch for your blog repository, then after 4-5 minutes your blog will be available at:
as you can view mine at: https://geekyshacklebolt.github.io/blog
I have been using GH Pages for long time and it’s been awesome always! You can publish your blogs, personal website, project docs, presentations, etc. free of cost and you also get free SSL. With this, I’ll culminate this trilogy of pelican tutorials.
Thanks for reading!
See you in the next post 🙂
1. Published GitHub Pages sites may be no larger than 1 GB.
2. GitHub Pages sites have a soft bandwidth limit of 100GB per month.
3. GitHub Pages sites have a soft limit of 10 builds per hour.