How to Deploy and Manage a Pelican Blog
Pelican is a popular open source static site generator written in Python. It allows you to convert markdown or reST formatted content into HTML pages using Jinja templates. Pelican is great for creating blogs, documentation sites, and simple websites. In this guide, I’ll walk through how to install Pelican, create and manage content, generate your site, and deploy it.
Prerequisites DELETE COPY CODE AND OTHER STUFF
- Python 3.x
- Pip (usually comes preinstalled with Python 3.x)
Install Pelican and Markdown
First, create and activate a virtual environment for your project, then install Pelican with markdown support:
python3 -m venv env
source env/bin/activate
pip install pelican[markdown]
Create a New Site
Use the pelican-quickstart
command to generate the initial folder structure and configuration file (pelicanconf.py
) for your site:
pelican-quickstart
Follow the prompts to specify your site title, author name, URL, timezone, etc. This will create a skeleton project in the current directory.
Add Your Content
Pelican supports Markdown and reST formatted content. Create your articles/pages in the content
folder. For example:
content/ - article1.md - page1.rst
Create/Edit Themes
The look and feel of your site is controlled by themes. Pelican comes with a default theme you can modify, or you can create/download other themes. Theme files live in the themes
folder.
Generate Your Site
Run this command from your project root to generate the HTML output from your content and themes:
pelican content
The HTML files will be output to the output
folder.
Preview Your Site
Install the HTTP server for previewing your site locally:
pip install pelican[dev] pelican --listen
This will launch a local web server at http://localhost:8000 where you can view your site.
Deploy Using SSH
To deploy your site via SSH:
- Generate the final HTML output:
pelican content -s pelicanconf.py
- Copy the
output
folder to your production server:scp -r output/ your_server:/path/to/webroot
- Set the permissions:
ssh your_server 'chown -R www-data:www-data /path/to/webroot'
Your Pelican site will now be live!
Custom Domains
To use a custom domain, configure your site’s URL in pelicanconf.py
and set up the domain with your DNS provider to point to your server IP.
Automate Publishing
You canautomate site generation and deployment using GitHub Actions, GitLab CI, or Jenkins. Or use the Makefile
included with Pelican which has commands like make devserver
and make publish
.
This covers the basics of managing a simple Pelican site! Pelican has many other powerful features for creating more complex sites and blogs. The documentation at https://docs.getpelican.com is a great resource to learn more. Let us know if you have any other questions!
Conclusion
This covers the basics of managing a simple Pelican site! Pelican has many other powerful features for creating more complex sites and blogs. The documentation at https://docs.getpelican.com is a great resource to learn more. Let me know if you have any other questions!
Keywords: How to, Guide, Walkthrough, Python, Pelican, Blog website