A Blog in 5 minutes

using Pelican and Github Pages

What is Pelican?

Pelican is a static web site generator, written in Python, that requires no database or server-side logic. Some of the features include:

  • Write your content in reStructuredText, Markdown, or AsciiDoc formats.
  • it has Themes that can be customized via Jinja templates.
  • We can publish our content in multiple languages.
  • Supports Atom / RSS feeds.
  • Completely static output is easy to host anywhere-

Install Pelican) is very easy, just run the following command:

sudo pip install pelican

What are Github Pages?

Github Pages is designed to host your web sites directly from a Github repository. They have an URL username.github.io, where username is your username on Github.

Creating the repository

In order to use Github Pages, we have to create a new repository with the name username.github.io in Github. (This will be our site internet address).

Cloning Github Pages and blog_template repositories

Once we have the repository created, we can clone it.

git clone https://github.com/usuarioGithub/usuarioGithub.github.io.git

Additionally, we can clone the blog_template repository, this repository has the initial setup to make it easier to create the site.

git clone https://github.com/blogen5minutos/blog_template.git

If you prefer not to use the blog_template, you can start your own Pelican project with the command:

pelican-quickstart

Editing pelicanconf.py and publishconf.py files

The main files with the Pelican configurations are pelicanconf.py and publishconf.py, in the last one we should include the configurations for the final publishing of the site.

If you are using the blog_template repository; you should change the variables SITENAME and SITESUBTITLE in the pelicanconf.py file and the variable SITEURL in the publishconf.py file.

Creating the content with Markdown

To create the site articles, we should create a Markdown or reStructuredText file in the content folder. For example, using Markdown, we can create the following file:

Title: My Blog

Date: 2016-05-18

Category: Python

Tags: python

Author: Raul E. Lopez Briega

Test article to show how easy is to create a blog in internet with [github pages](https://pages.github.com/).

For more information, visit the Pelican documentation.

Creating articles with Jupyter notebooks

Other way to create articles, is using Jupyter notebooks. We will need to install the plugin liquid_tags.

Once the plugin is enable in the pelicanconf.py file; we should save ours notebooks in the subfolder notebooks inside the content folder and then write a new Markdown file, using the following syntax in the end:

{% notebook filename.ipynb [ cells[start:end] ]%}

For example:

Title: Batman, ecuaciones y python

Date: 2016-05-19

Category: Python

Tags: python, matematica, programacion, batman

Author: Raul E. Lopez Briega

{% notebook Batman.ipynb cells[2:] %}

Creating the site

Once we have configurated the Pelican project and the articles are ready; we can create the site with the following command:

make html

This command will create a new folder named output with all the content for running our site. We can test the results with the command:

make serve

and then going to localhost:8000 to see the site.

If everything is fine, we can create the final version with the command:

make publish

Publishing the site

To publish our site, we have to copy the content of output folder into the username.github.io folder and then committing and pushing the changes.

git add --all

git commit -m "publicando blog"

git push -u origin master

Congratulations, the site is ready! we can visit the site at https://username.github.io.