Introduction
This blog is build using Pelican. Here's a few quick and dirty setup instructions, so you can get started with a Pelican based blog yourself.
Pre-requisites
General utilities
Pelican is written in Python, so it would be useful to have python
and pip
installed and available.
Also, many themes and plugins are hosted on github, so having git available is super convenient.
We can install the rest of the tools using pip, and git.
# Ubuntu
sudo apt install python3-pip git
(Optional) Virtual environment
To keep the system packages tidy, we can install all blog related packages into a separate virtual environment.
venv
is the recommended minimal virtual environment manager for Python.
# Ubuntu
sudo apt install python3-venv
Create an environment and activate it.
# Create
python3 -m venv --upgrade-deps --prompt pelican ~/.venvs/pelican
# Activate
source ~/.venvs/pelican/bin/activate
Pelican tools
python3 -m pip install pelican
Pelican blog
A Pelican blog directory essentially consists of content, config and output.
./
|-- Makefile
|-- content/
|-- output/
|-- pelicanconf.py
|-- publishconf.py
`-- tasks.py
We can use the pelican-start
script to help us get started with a rudimentary blog quickly.
# In a new directory that will house your blog (am using /tmp/peliblog for demo)
pelican-quickstart
Welcome to pelican-quickstart v4.8.0. This script will help you create a new Pelican-based website. Please answer the following questions so this script can generate the files needed by Pelican. > Where do you want to create your new web site? [.] > What will be the title of this web site? Tutorial blog for Pelican > Who will be the author of this web site? Luciuos Luis > What will be the default language of this web site? [en] > Do you want to specify a URL prefix? e.g., https://example.com (Y/n) y > What is your URL prefix? (see above example; no trailing slash) https://tut.pelican.test/blog > Do you want to enable article pagination? (Y/n) y > How many articles per page do you want? [10] 20 > What is your time zone? [Europe/Rome] > Do you want to generate a tasks.py/Makefile to automate generation and publishing? (Y/n) y > Do you want to upload your website using FTP? (y/N) n > Do you want to upload your website using SSH? (y/N) n > Do you want to upload your website using Dropbox? (y/N) n > Do you want to upload your website using S3? (y/N) n > Do you want to upload your website using Rackspace Cloud Files? (y/N) n > Do you want to upload your website using GitHub Pages? (y/N) n Done. Your new project is available at /tmp/peliblog
This will give us a basic pelican blog project directory that we can work with.
When you write your plain text blog articles you should always place them in the content directory.
Formats like .md, .rst are supported by Pelican.
Sample blog file: oh-my-fortune.md
Note: The Title key (first line shown below) is necessary, rest keys are optional.
Title: Oh my fortune!
Date: 1947-08-15
Category: Speeches
# Tryst
## Remember the past
Long years ago we made a tryst with destiny, and now the time comes when we shall redeem our pledge, not wholly or in full measure, but very substantially.
## Look around
The ambition of the greatest man of our generation has been to wipe every tear from every eye. That may be beyond us, but as long as there are tears and suffering, so long our work will not be over.
Peace has been said to be indivisible; so is freedom, so is prosperity now, and so also is disaster in this one world that can no longer be split into isolated fragments.
## Embrace freedom
We rejoice in that freedom, even though clouds surround us, and many of our people are sorrow-stricken and difficult problems encompass us. But freedom brings responsibilities and burdens and we have to face them in the spirit of a free and disciplined people.
We think also of our brothers and sisters who have been cut off from us by political boundaries and who unhappily cannot share at present in the freedom that has come. They are of us and will remain of us whatever may happen, and we shall be sharers in their good and ill fortune alike.
## Hope
The future beckons to us. Whither do we go and what shall be our endeavour?
We are citizens of a great country, on the verge of bold advance, and we have to live up to that high standard.
A new star rises, the star of freedom in the east, a new hope comes into being, a vision long cherished materialises. May the star never set and that hope never be betrayed!
./
|-- Makefile
|-- content/
| `-- oh-my-fortune.md
|-- output/
|-- pelicanconf.py
|-- publishconf.py
`-- tasks.py
Now running pelican
in our blog directory will build the blog and save .html and other necessary files to output/
pelican
[17:50:30] WARNING Watched path does not exist: /tmp/peliblog/content/images log.py:91 Done: Processed 1 article, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.06 seconds.
./
|-- Makefile
|-- __pycache__/
| `-- pelicanconf.cpython-310.pyc
|-- content/
| `-- oh-my-fortune.md
|-- output/
| |-- archives.html
| |-- author/
| |-- authors.html
| |-- categories.html
| |-- category/
| |-- index.html
| |-- oh-my-fortune.html
| |-- search.toml
| |-- tags.html
| `-- theme/
|-- pelicanconf.py
|-- publishconf.py
`-- tasks.py
You can now host the output/
directory on any web-server as a static website!
To see a local demo of your blog and edit live:
pelican -autoreload --listen
There you go. You have your own Pelican blog ready.
Now, you would obviously like to customise your blog with themes and plugins.
For that, stay tuned for the next article in this series.
(Or look up for Pelican themes online and try piecing it together yourself!)
🫡
Ref: Pelican Docs