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 devservergo tohttp://localhost:8000/ - It builds the
outputdir
Structure
contentholds all contents,
outputhas all the static pages built using content and theme.
Adding Theme
- Make a themes dir anywhere
- add this dir to
pelicanconf.pyasTHEME = 'themes_dir/my_theme my_themeshould have two foldersstaticall your css, js and images can go here, copied as-is to outputtemplatestemplates for various mandatory pagesbase.htmlstarting point, linkshref="{{ SITEURL }}/theme/css/my.css">page.htmlimports base and adds content for pagesindex.htmllists 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 devservergo tohttp://localhost:8000/ - this will launch the site and will autoupdate site on page modifications.
Production Push
- Delete the output dir
- run
make devservergo tohttp://localhost:8000/verify all changes - then make an archive of
outputfolder 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.pyaddPAGE_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