[PYTHON] Blog on Nikola

What is Nikola?

Nikola is a static site generator made by Python.

Official site: https://getnikola.com

Jekyll, HUGO, Hexo, etc. seem to be major static site generators. Pelican is famous for Python.

This is one of the reasons why I chose Nikola this time.

Nikola input format

The default reStructuredText is familiar to Sphinx users, and you can post a Notebook (ipynb) created with Jupyter as it is as a blog. It seems to have a high affinity for Pythonista and data scientists.

Formats supported by default

Formats that can be supported by Plugin

Installation

There are various installation methods, but it seems better to install with pip.

pip install Nikola

Although the explanation is omitted in this article, it is recommended to install it in a virtual environment such as venv or virtualenv.

Creating a site

Commands for initialization are provided. Answer a few questions and your site will be created. The site_name below is any directory name. A directory will be created with the specified name.

nikola init site_name
Creating Nikola Site
====================

This is Nikola v7.8.8.  We will now ask you a few easy questions about your new site.
If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter.
--- Questions about the site ---
Site title [My Nikola Site]: 

Enter the title of your site.

Site author [Nikola Tesla]: 

Enter your name.

Site author's e-mail [[email protected]]:

Enter your email address.

Site description [This is a demo site for Nikola.]:

Enter a description for your site.

Site URL [https://example.com/]: 

Enter the URL of your site.

Enable pretty URLs (/page/ instead of /page.html) that don't need web server configuration? [Y/n]

Enter Y to enable pretty URLs.

--- Questions about languages and locales ---
We will now ask you to provide the list of languages you want to use.
Please list all the desired languages, comma-separated, using ISO 639-1 codes.  The first language will be used as the default.
Type '?' (a question mark, sans quotes) to list available languages.
Language(s) to use [en]:

Enter the language you want to use. For Japan, enter ja.

Please choose the correct time zone for your blog. Nikola uses the tz database.
You can find your time zone here:
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Time zone [UTC]: 

Enter the time zone. For Japan time, enter ʻAsia / Tokyo`.

--- Questions about comments ---
You can configure comments now.  Type '?' (a question mark, sans quotes) to list available comment systems.  If you do not want any comments, just leave the field blank.
Comment system:

Enter if you use the comment system. Leave blank if not in use. As of June 17, 2017, the following items can be used.

Posting an article

The following command will generate a template text file.

nikola new_post
Creating New Post
-----------------

Title: 

Entering the title of the article will generate a post / titlename.rst file. Edit this file with an editor. The default is reStructuredText format.

.. title: {{Enter the title of the article.}}
.. slug: {{Article path(file name)Enter the.}}
.. date: {{Enter the posting date and time. UTC at the end for Japan time+09:00 is attached.}}
.. tags: {{Enter the tag. You can specify multiple tags separated by commas.}}
.. category: {{Enter the category.}}
.. link: {{Enter the link if there is a reference source.}}
.. description: {{Enter the description meta tag.}}
.. type: text

{{Enter the content of the article here.}}

To create an article in Markdown format, use the -f option and specify as follows.

nikola new_post -f markdown
Creating New Post
-----------------

Title:

Entering the title of the article will generate a post / titlename.md file. Edit this file with an editor.

<!--
.. title: {{Enter the title of the article.}}
.. slug: {{Article path(file name)Enter the.}}
.. date: {{Enter the posting date and time. UTC at the end for Japan time+09:00 is attached.}}
.. tags: {{Enter the tag. You can specify multiple tags separated by commas.}}
.. category: {{Enter the category.}}
.. link: {{Enter the link if there is a reference source.}}
.. description: {{Enter the description meta tag.}}
.. type: text
-->

{{Enter the content of the article here.}}

Site build

Build the article posted above with the command below.

nikola build

Site confirmation

The following command will start the http server. The browser is started by adding the -b option.

nikola serve -b

The site is displayed like this.

image.png

Next time will show you how to post a Jupyter Notebook file (ipynb) as a blog post.

Recommended Posts

Blog on Nikola
Use Github-Flavored-Markdown on your Pelican blog
Django blog on heroku: login implementation