Skip to content
Gabx edited this page Mar 19, 2016 · 6 revisions

Pelican blog

Pelican is a static site generator, written in Python. It is a very simple and easy to deploy. It allows to generate HTML pages from Markdown documents. The page can be visualized when running pelikan server on 192.168.1.94:8000

Install python-pelican

There is a Fedora package.

# dnf install python-pelican

This will install the package with all its dependencies

Create a directory where contents will be stored:

$ mkdir /storage/tth_blog/

NOTE: this directory is refered in some .html pages as {{ SITEURL }}

Change directory to tth_blog, and run the following command to initialize:

$ pelican-quickstart

Answer the questions. Do not specify a site URL as we will only run locally for testing before publishing.

Now, write a .md file in the content directory and run at the root directory:

$ pelican content

Change directory to output and run:

$ python -m SimpleHTTPServer

Now visit the 192.168.1.94:8000 page. Control + C to stop the server.

configuration

Once installed, the directory structure is the following:

yourproject/
├── content
│   └── (pages)
├── output
├── develop_server.sh
├── fabfile.py
├── Makefile
├── pelicanconf.py       # Main settings file
└── publishconf.py       # Settings to use when ready to publish

The main configuration file is pelicanconf.py.

themes

We modified the simple theme with this git: https://github.com/jo-tham/pure-single

$ mkdir -p pelican-themes/pure-single
$ git clone https://github.com/jo-tham/pure-single pelican-themes/pure-single
$ tree -a -L 2 pure-single
├── static
│   ├── css
│   └── images
└── templates
    ├── archives.html         // to display archives
    ├── period_archives.html  // to display time-period archives
    ├── article.html          // processed for each article
    ├── author.html           // processed for each author
    ├── authors.html          // must list all the authors
    ├── categories.html       // must list all the categories
    ├── category.html         // processed for each category
    ├── index.html            // the index (list all the articles)
    ├── page.html             // processed for each page
    ├── tag.html              // processed for each tag
    └── tags.html             // must list all the tags. Can be a tag cloud.

Install the theme:

$ pelican-themes -vi pelican-themes/pure-single

List themes:

% pelican-themes -v -l
/usr/lib/python2.7/site-packages/pelican/themes/notmyidea
/usr/lib/python2.7/site-packages/pelican/themes/simple
/usr/lib/python2.7/site-packages/pelican/themes/pure-single

See the theme in action:

$ make devserver

use Font Awsome

$ git clone https://github.com/FortAwesome/Font-Awesome

In the

of your html, reference the location to your font-awesome.min.css.
<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">

templates

The templates used are listed in {{ SITEURL }}/pelican-themes/pure-single/templates directory. To modify any .html settings, edit one the files from this directory.

make a new post

$ fab make_entry:"New Post"

or

$ make newpost NAME='Your Exciting Post Name Here'

URL settings

The first thing to understand is that there are currently two supported methods for URL formation: relative and absolute. Relative URLs are useful when testing locally, and absolute URLs are reliable and most useful when publishing.

common variables for publishing

  • output file The name of the file currently being generated. For instance, when Pelican is rendering the home page, output_file will be “index.html”.

  • articles The list of articles, ordered descending by date. All the elements are Article objects, so you can access their attributes (e.g. title, summary, author etc.). Sometimes this is shadowed (for instance in the tags page). You will then find info about it in the all_articles variable.

  • dates The same list of articles, but ordered by date, ascending.

  • drafts The list of draft articles

  • tags A list of (tag, articles) tuples, containing all the tags.

  • categories A list of (category, articles) tuples, containing all the categories and corresponding articles (values)

  • pages The list of pages

  • hidden_pages The list of hidden pages

plugins

run on Nginx

The devserver is just a wrapper around python -m SimpleHTTPServer, which as the name suggests is a very simple web server that does not have all the rewriting features of nginx. The best solution here is to install and configure nginx locally to match the server-side configuration.

Resources

Clone this wiki locally