Pelican
Pelican is a static site generator in Python.
Quickstart
- make a dir
- create virtual env
python3 -m venv venv
- upgrade pip
./venv/bin/pip install --upgrade pip
- activate env
source venv/bin/activate
- install pelican
pip install pelican
- create basic files and dir
pelican-quickstart
- start server
make devserver
go tohttp://localhost:8000/
- It builds the
output
dir
Structure
content
holds all contents,
output
has all the static pages built using content and theme.
Adding Theme
- Make a themes dir anywhere
- add this dir to
pelicanconf.py
asTHEME = 'themes_dir/my_theme
my_theme
should have two foldersstatic
all your css, js and images can go here, copied as-is to outputtemplates
templates for various mandatory pagesbase.html
starting point, linkshref="{{ SITEURL }}/theme/css/my.css">
page.html
imports base and adds content for pagesindex.html
lists all blog articles- other pages are mandatory like article, author, tag etc can be copied from here.
Dev Sprints
- Go to folder
- activate env
source venv/bin/activate
- start server
make devserver
go tohttp://localhost:8000/
- this will launch the site and will autoupdate site on page modifications.
Production Push
- Delete the output dir
- run
make devserver
go tohttp://localhost:8000/
verify all changes - then make an archive of
output
folder and upload to your host. - for GCP please follow steps here.
Tips and Tricks
- to replace blog index page, add following metas to any new
homepage.html
- sorting menu items
- in
pelicanconf.py
addPAGE_ORDER_BY = 'reversed-date'
- then in pages meta add
<meta name="date" content="2020-07-26 07:00" />
- you can then change time to sort pages in menu bar.
- in
Minimum html required for pages:
<html>
<head>
<title>My super title</title>
</head>
<body>
This is the content of my super blog post.
</body>
</html>
To do:
- exclude some pages from menu
- add articles
2025-01-12
Aug 2020