Skip to content

Instantly share code, notes, and snippets.

@dunderrrrrr
Created February 21, 2020 13:32
Show Gist options
  • Save dunderrrrrr/9aabe758072cae00eeaa6846b75eb9f6 to your computer and use it in GitHub Desktop.
Save dunderrrrrr/9aabe758072cae00eeaa6846b75eb9f6 to your computer and use it in GitHub Desktop.
Pelican is a static site generator that requires no database or server-side logic.

Pelican is a static site generator that requires no database or server-side logic.

Pelican currently runs best on Python 2.7.x; earlier versions of Python are not supported. There is provisional support for Python 3.3+, although there may be rough edges, particularly with regards to optional 3rd-party components. However, it sure does work with 3.6.

Set up Pelican

Create a user and virtualenv

$ sudo adduser pelican
$ sudo su - pelican
(pelican)$ mkvirtualenv --python="/usr/bin/python3" pelican

Install Pelican requirements

(pelican)$ pip install pelican markdown

Create a project

(pelican)$ mkdir -p ~/projects/yoursite
(pelican)$ cd ~/projects/yoursite
(pelican)$ pelican-quickstart

Follow the instructions.

Create an article

(pelican)$ nano ~/projects/yoursite/content/my-first-content.md
Title: My First Review
Date: 2010-12-03 10:20
Category: Review

Following is a review of my favorite mechanical keyboard.

Generate site

From your site root dir (~/projects/yoursite)

(pelican)$ pelican content

Set up nginx

$ sudo apt install nginx
$ sudo touch /etc/nginx/sites-available/yoursite.com
server {
        #listen [::]:80;
        root /home/pelican/projects/yoursite/output;
        index index.html index.htm index.nginx-debian.html;

        server_name yoursite.com www.yoursite.com;

        location / {
                try_files $uri $uri/ =404;
        }
}

Reload nginx and view your site.

$ sudo service nginx reload

Add content to Pelican

(pelican)$ cd ~/projects/yoursite/
(pelican)$ nano content/your-article.md

Add your content in markdown syntax.

(pelican)$ pelican content
Done: Processed 3 articles, 0 drafts, 0 pages, 0 hidden pages and 0 draft pages in 0.50 seconds.

Custom CSS/JS

Add the following to pelicanconf.py

CUSTOM_CSS = 'static/css/custom.css'
CUSTOM_JS = 'static/js/custom.js'

Create folders and files in ~/projects/yoursite/static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment