Pelican Sheet Notes

Posted on December 20, 2017 in website

A static webpage is a collection of pages written in HTML, CSS or JavaSript. A lot of researchers, professors and students have been using it to create personal homepages to share their respective projects, blogs and any other desired information. The difficulty here is that when the website becomes larger or more complex, it gets more complicated and more time is spent to add new content.

To overcome this issue, the use of Static Site Generator has increased over the last couple of years. Now, we do not need to constantly pay attention in the webdesign of the pages; instead we can just focus on creating the content to publish in the website. The static site generator allows users to create HTML files by creating markup language files, such as, Markdown or reStructuredText. There are several engines to perform this task, such as:

One example of webpage generated by this tool is this website. I used the Pelican Engine which is written in Python. Here I will describe some procedures to install, create and publish a website. My focus is just to write this content mostly to save it for my own future references, since there are so many posts on the Internet about this subject.

Environment Configuration

I created an isolated Python Environment for this project using Virtualenv.

1
sudo pip install virtualenv

Now, it is necessary to create an environment for the Pelican and install the packages.

1
2
3
4
5
virtualenv ~/virtualenvs/pelican
cd ~/virtualenvs/pelican
source bin/activate
pip install pelican
pip install Markdown

In this post I used the Markdown just to illustrate the task; however, you can also use reStructuredText (RST). There are a great number of posts on the Internet talking about the difference between those markup languages. (Read "reStructuredText vs Markdown for documentation" by Victor Zverovich).

To start your website, you can use:

1
pelican-quickstart

Then you will answer some questions about the project you are using to create the files according with your desired settings.

Directories

For my project I created the following directories:

  • content:
    • articles;
    • pages;
    • images.
  • Theme;
  • Plugins.

In the Plugin folder you add a clone repository for the Pelican-plugins:

1
git clone git@github.com:getpelican/pelican-plugins.git

For the Theme folder you can use the Pelican-Themes or create your own:

1
git clone git@github.com:getpelican/pelican-themes.git

For the content, you will add your content in a markup language format in which you desire to publish.

Modify settings in pelicanconf.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
from os.path import join, expanduser

AUTHOR = u'Erivelton Gualter'
SITENAME = u"Erivelton' Homepage"
SITEDESCRIPTION = '%s\'s Thoughts and Writings' % AUTHOR
SITESUBTITLE = 'PhD Student at Cleveland State University'
SITEURL = 'https://eriveltongualter.github.io/blog/'

RELATIVE_URLS = False

PATH = 'content'

TIMEZONE = 'US/Central'

DEFAULT_LANG = u'en'

DATE_FORMATS = {
    'en': '%B %d, %Y',
}

# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

PYGMENTS_STYLE = 'igor'

#PYGMENTS_RST_OPTIONS = {'classprefix': 'pgcss', 'linenos': 'table'}
PYGMENTS_RST_OPTIONS = {'linenos': 'table'}

LOAD_CONTENT_CACHE = False

# Blogroll
LINKS = (('Old Homepage', 'https://eriveltongualter.github.io/'),)

# Social widget
SOCIAL = (('linkedin', 'https://www.linkedin.com/in/EriveltonGualter'),
          ('github', 'https://github.com/EriveltonGualter'),
          ('twitter', 'https://twitter.com/EGualter'),)

USE_FOLDER_AS_CATEGORY = False
MAIN_MENU = True
#HOME_HIDE_TAGS = True

MENUITEMS = (("Archives", "/blog/archives.html"),
             ("Categories", "/blog/categories.html"),
                 ("Tags", "/blog/tags.html"),)

PLUGIN_PATHS = [join(expanduser("~"), 'src', 'pelican-plugins'), "plugins"]
PLUGINS = ['pelican_youtube']

DISQUS_SITENAME = 'DISQUS_SITENAME'

DEFAULT_METADATA = {'yeah': 'it is'}

COPYRIGHT_YEAR = 2017

DEFAULT_PAGINATION = 10

THEME = 'Flex'

# Uncomment following line if you want document-relative URLs when developing
RELATIVE_URLS = True

Run and Publish

1
2
3
4
make html
pelican content -o output -s pelicanconf.py
ghp-import output
git push git@github.com:EriveltonGualter/blog.git gh-pages:master