Setting up Pelican & Netlify

This post provides a quick summary of the essential steps for setting up a basic static blog with Pelican and bringing it online with Netlify.

Steps

Create a folder & virtual environment:

# Create the folder & venv
mkdir netlify && cd netlify
python3 -m venv venv --copies
source venv/bin/activate
# Install relevant packages
pip install pelican Markdown 

Kick-Start the Pelican Project:

pelican-quickstart

Create a new Github repository (can be private) and push the code. Add a runtime.txt file with content 3.8 to the root folder of the repo to ensure Netlify uses Python 3.8 (and not 2.7 which, despite being deprecated, is still their default).

Choose a theme (from Pelican Themes or Awesome Pelican) and install/copy it to the blog_root/theme sub-directory.

Create an Account on Netlify (Link) and link it to the freshly created Github Repo. During the configuration set pelican content -s publishconf.py -t theme as the build command and output as the publishing directory.

To create a simple first post paste the following into blog_root/content/first-post.md:

---
Title: Let's get this blog started!
Date: 2021-12-12 20:00
Category: Announcement
Tags: Pelican, Announcement
Slug: first-post
Authors: You
Status: Published
---

## Big heading for a big day!

Some text..

THE END.

Most attributes above should be self-explaining. The Slug represents the final part of the URL under which the post will be accessible. The Status is used to control whether an article is visible on the page. It takes on a value of either Draft or Published.

You can preview the page locally by running the following commands from the blog root directory:

# (Re-)build the website
make html
# Start a local web server to preview the page
make devserver

Then, if everything looks good, publish it by pushing the changes to Github. Netlify should automatically pick up the new commit and bring the changes live.

git add .
git commit -m "First blog post"
git push

That's it. This is all that is required to set up a simple static page/blog.


Published

Category

Web Development

Tags

Contact