Streamlining Deployment with Pelican and GitHub Pages
As a blogger who uses Pelican and GitHub Pages to power and host my blog, I’ve found a workflow that works well for me when deploying new posts. In this post, I’ll share that workflow with you.
Pelican is a static site generator that automatically generates HTML files from content written in Markdown. GitHub Pages, on the other hand, is a service provided by GitHub for hosting websites under a
While using Pelican and GitHub Pages is straightforward, there is a small issue that arises. GitHub Pages assumes that the root folder of the master branch is the folder that should be served to the world. However, Pelican’s default settings output the generated website files to an output folder. This discrepancy can be solved by either using two separate repositories for source and output files or by using branches and git hooks.
Personally, I prefer to keep everything in one place, so I use branches and git hooks to manage my blog deployment. I create two branches in my GitHub Pages repository – one for the source files (e.g., content folder and pelicanconf.py) and one for the output contents. This allows me to keep all my blog-related files in one repository.
To automate the process of updating the master branch with the new contents of the output folder whenever I push a commit to the source branch, I use a pre-push git hook. This custom script executes the necessary commands to update the master branch with the latest version of the website’s production files.
By utilizing git hooks and branches, I can easily manage the deployment of new blog posts without the need for separate repositories. This streamlined workflow allows me to focus on creating content and updating my blog without getting bogged down by manual deployment tasks.
Overall, using Pelican and GitHub Pages in conjunction with branches and git hooks has made managing my blog deployment process much more efficient. If you’re looking for a simple and effective way to deploy your blog posts, I highly recommend giving this workflow a try.