Creating a Blog with Pelican Static Site Generator¶
Pelican is a static site generator written in Python that transforms content written in Markdown or reStructuredText into static websites. It's particularly well-suited for blogs and portfolio sites.
In this tutorial, I'll show you how to set up a Pelican blog, customize its theme, add content, and deploy it as a static site with Appliku.
Requirements¶
For this tutorial you need:
- Python 3.9 or higher installed on your computer
- git
- GitHub account
- Appliku Account
Repository:¶
Source code is available on GitHub appliku/pelicantutorial
Create a Pelican project¶
First, let's set up our environment and install dependencies:
mkdir pelican-blog
cd pelican-blog
python3 -m venv env
source env/bin/activate
pip install pelican markdown
pip freeze > requirements.txt
Initialize your Pelican site:
pelican-quickstart
Answer the questions prompted. Here are recommended answers: - Where do you want to create your new web site? [.] - What will be the title of this web site? [Your Blog Title] - Who will be the author of this web site? [Your Name] - What will be the default language of this web site? [en] - Do you want to specify a URL prefix? [no] - Do you want to enable article pagination? [yes] - How many articles per page? [10] - Do you want to generate a tasks.py/Makefile? [no]
Create .gitignore
file:
env/
*.pyc
__pycache__/
output/
.DS_Store
.env
*.pid
Create Content¶
Create a directory for your articles:
mkdir content
Create your first article in content/first-post.md
:
Title: My First Post
Date: 2024-12-26 10:20
Category: Python
Tags: pelican, publishing
Slug: first-post
Author: Your Name
Summary: Short version of my first post
This is my first blog post using Pelican.
Welcome to my blog!
Configure Pelican¶
Edit pelicanconf.py
to customize your site:
AUTHOR = 'Your Name'
SITENAME = 'My Blog'
SITEURL = ''
PATH = 'content'
TIMEZONE = 'Europe/Belgrade'
DEFAULT_LANG = 'en'
# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
# Social widget
SOCIAL = (
('GitHub', 'your-github-url'),
('Twitter', 'your-twitter-url'),
)
DEFAULT_PAGINATION = 10
# Uncomment following line if you want document-relative URLs when developing
# RELATIVE_URLS = True
Generate Your Site¶
Generate your site with:
pelican content
To preview locally, run:
pelican --listen
Visit http://localhost:8000
in your browser.
Commit and Push to GitHub¶
Initialize git repository and commit your changes:
git init
git add .
git commit -m "Initial commit"
Create a new repository on GitHub and push your code:
git remote add origin your-repository-url
git push -u origin master
Deploy with Appliku¶
Go to your Appliku dashboard and create a new application from GitHub repository.
Create and add a server for Pelican Blog¶
Add an Ubuntu or a Debian server from a cloud provider of your choice, if you haven't already.
Here are guides for adding servers from different cloud providers:
- Deploy Django on Hetzner
- Deploy Django on Digital Ocean Droplet
- Deploy Django on AWS EC2 Instance
- Deploy Django on Linode
- Deploy Django on Azure Virtual machine
- Deploy Django on Google Cloud Platform Virtual Machine
Create Static Site Application¶
- Go to Applications -> GitHub
- Give your application a name
- Choose your GitHub repository
- Select the branch
- Check "This is a static site"
- Choose your server
- Click Create Application
Configure Build Settings¶
Go to Application Settings.
In the application settings, Build Settings Tab:
- Set Base Docker Image to Python 3.12
- Set build command to:
pelican content
- Set output directory to:
output
- Save changes and deploy
Your site will be built and deployed automatically.
Go back to the application page, click Open App and click on the domain name.
Congrats, your static site blog with Pelican is deployed!
It has a default subdomain with HTTPS. You can add your custom domain in application settings.