How to set up a Nikola-powered blog with multi-markup support
Tags: jupyternotebooks, nikola, nikolassg, ssgblog
Published: 2024-06-19 04:29:33

---
title: How to set up a Nikola-powered blog with multi-markup support
published: true
date: 2024-05-07 07:00:00 UTC
tags: jupyternotebooks,nikola,nikolassg,ssgblog
canonical_url: https://diegocarrasco.com/nikola-blog-setup/
---

![](https://diegocarrasco.com/images/social-images/nikola-blog-setup.jpg)

 

- [TL;DR](https://diegocarrasco.com/nikola-blog-setup/#tldr)
- [Context](https://diegocarrasco.com/nikola-blog-setup/#context)
- [What is a static site generator and what's the difference with normal CMSs](https://diegocarrasco.com/nikola-blog-setup/#what-is-a-static-site-generator-and-whats-the-difference-with-normal-cmss)
  - [Key Differences Between SSGs and Traditional CMSs](https://diegocarrasco.com/nikola-blog-setup/#key-differences-between-ssgs-and-traditional-cmss)
- [Steps](https://diegocarrasco.com/nikola-blog-setup/#steps)
  - [1. Install Nikola](https://diegocarrasco.com/nikola-blog-setup/#1-install-nikola)
  - [2. Create Your Nikola Site](https://diegocarrasco.com/nikola-blog-setup/#2-create-your-nikola-site)
  - [3. Configure Nikola](https://diegocarrasco.com/nikola-blog-setup/#3-configure-nikola)
  - [4. Setting Up Version Control](https://diegocarrasco.com/nikola-blog-setup/#4-setting-up-version-control)
    - [GitHub vs. GitLab](https://diegocarrasco.com/nikola-blog-setup/#github-vs-gitlab)
    - [Using GitLab](https://diegocarrasco.com/nikola-blog-setup/#using-gitlab)
  - [5. Edit and Update Your Blog](https://diegocarrasco.com/nikola-blog-setup/#5-edit-and-update-your-blog)
  - [6. Link to Deployment Guide](https://diegocarrasco.com/nikola-blog-setup/#6-link-to-deployment-guide)
- [Conclusion](https://diegocarrasco.com/nikola-blog-setup/#conclusion)
- [Check the Handbook](https://diegocarrasco.com/nikola-blog-setup/#check-the-handbook)
- [Check my other articles on nikola](https://diegocarrasco.com/nikola-blog-setup/#check-my-other-articles-on-nikola)

## TL;DR

This article guides you through creating a blog using Nikola, a static site generator that supports Markdown, reStructuredText, and Jupyter Notebooks. I'll use the Bootblog theme and detail how to host the code in a private repository on GitHub or GitLab, with a preference for GitLab. Deployment steps to Cloudflare are covered in a separate article (link provided). For editing, VSCode or PyCharm is recommended, though any text editor works.

## Context

Nikola is a versatile static site generator that is perfect for researchers, educators, and bloggers who want to incorporate rich content like Jupyter Notebooks into their posts. It's Python-based, easy to customize, and supports various content types.

After extensive research and testing various static site generators, I chose Nikola as my blogging platform. While Nikola may not be as trendy as some newer generators that frequently pop up in tech articles, my priority was finding a tool that offered both stability and flexibility—qualities that are sometimes overlooked in favor of following trends.

Nikola stood out for me for several reasons:

- **Stability** : The project has been actively maintained for over eight years, indicating a mature and dependable platform.
- **Flexibility** : Written in Python, Nikola is particularly advantageous for those involved in DevOps and Data Science. It supports a wide array of formats and markup languages including AsciiDoc, Markdown, Jupyter Notebooks, and HTML and allows importing metadata and content also from several sources (WordPress, Pelican and others). Here you have a [cheat sheet for some markup languages](https://diegocarrasco.com/markup-languages-cheatsheet/)
- **Extensibility** : The availability of shortcodes and plugins enhances its functionality, allowing for a high degree of customization and integration. I've [created some shortcodes myself](https://diegocarrasco.com/nikola-custom-shortcodes) for my personal use case
- **Deployment Versatility** : It can be deployed to virtually any platform, though I personally use [Cloudflare Pages](https://diegocarrasco.com/deploy-nikola-site-cloudflare-pages) for its simplicity and performance.
- **Version Control Friendly** : The content being stored in plain formats in a Git repository (I use [GitLab](https://gitlab.com)) means that it's not only secure but also highly manageable and version-controlled.

This combination of features makes Nikola an ideal choice for me (and I dare say for those who value a stable, extendable, and developer-friendly blogging environment).

## What is a static site generator and what's the difference with normal CMSs

A **static site generator (SSG)** is a tool used to produce HTML websites by compiling source files written in various markup languages like Markdown or reStructuredText. Unlike traditional content management systems (CMSs) that dynamically build a page every time a user accesses it, SSGs generate (compile) all pages at once during development. This process results in a set of static HTML files which can be easily hosted and served.

### Key Differences Between SSGs and Traditional CMSs

- **Performance** : Static sites generally load faster than their CMS counterparts because they consist of simple HTML files, eliminating the need to query a database or execute server-side scripts on each request.
- **Security** : With fewer moving parts and no database interactions, static sites are less vulnerable to common web attacks such as SQL injection and XSS (Cross-Site Scripting).
- **Scalability** : Hosting static files is straightforward and can handle high traffic with less overhead than dynamic sites.
- **Cost** : Static sites can be hosted on any simple web server or services like GitHub Pages and Cloudflare Pages often for free, reducing the cost associated with web hosting.
- **Maintenance** : Static sites require less maintenance since they don’t involve managing a server or database. Updates are made by regenerating and redeploying the site, rather than through an online interface. This means you don't need to update anything, and you may use an old version forever, so long it runs locally.

However, traditional CMSs like WordPress or Drupal offer advantages in scenarios requiring frequent updates, user interaction, or complex dynamic functionalities. They provide a user-friendly interface that allows non-technical users to easily manage content and make updates in real-time without touching the underlying code. And traditional CMSs are friendlier for a normal user.

## Steps

Here's how to set it up on any major operating system and prepare it for hosting on Cloudflare.

### 1. Install Nikola

First, you need to install Nikola. It's Python-based, so ensure Python is installed on your system.

I recommend to use a [virtual environment](https://diegocarrasco.com/python-development-ecosystem-essential-tools/#_virtual_environments). I usually use miniconda. You can check the install instructions [here](https://docs.anaconda.com/free/miniconda/miniconda-install/).

Once you have Python installed (with or without a virtual environment) you need to install `nikola`.

```
pip install Nikola[extras]

```

### 2. Create Your Nikola Site

Generate your new Nikola site with:

```
nikola init mysite
cd mysite

```

### 3. Configure Nikola

Edit `conf.py` in your site directory to set up the Bootblog theme and enable support for Markdown, reStructuredText, and Jupyter Notebooks:

```
# Add bootblog to your theme
THEME = "bootblog"

# Enable support for Markdown, reStructuredText, and Jupyter Notebooks
COMPILERS = {
    "rest": ['.rst'],
    "markdown": ['.md'],
    "ipynb": ['.ipynb']
}

```

### 4. Setting Up Version Control

#### GitHub vs. GitLab

**GitHub:** - More popular and widely used. - Integrates well with other tools and services. - Provides free private repositories with a limit on collaborators.

**GitLab:** - Offers free private repositories with unlimited collaborators. - Includes built-in CI/CD features. - I prefer GitLab for its comprehensive DevOps capabilities.

#### Using GitLab

Create anew account on https://about.gitlab.com/pricing/ on the free plan and then create a new private repository in GitLab and push your site:

```
git init
git remote add origin [your-gitlab-repository-url]
git add .
git commit -m "Initial commit"
git push -u origin master

```

### 5. Edit and Update Your Blog

For updating your blog, use VSCode or PyCharm, though any text editor will suffice. These IDEs offer great support for Python and Markdown, enhancing the blogging workflow.

### 6. Link to Deployment Guide

For steps on deploying your blog to Cloudflare, refer to my detailed guide here: [Deploying Nikola Site to Cloudflare](https://diegocarrasco.com/deploy-nikola-site-cloudflare-pages).

Nikola has a `deploy` command, but I prefer to use the Cloudflare pipeline to auto-publish on `git push`.

## Conclusion

Setting up a Nikola blog is straightforward (but requires more steps than setting a blog on WordPress.com). It supports a variety of content formats and can be easily integrated into modern workflows and tools like GitLab and Cloudflare for a robust blogging setup. The best of it is that you are not dependent on a specific platform.

## Check the Handbook

The handbook on https://getnikola.com/handbook.html is great and has almost everything you might need for your blog.

## Check my other articles on nikola

I've writen some articles about nikola that might interest you after this one

<!-- Begin post-list post_list_f9e8fd7ce4d147f0a1252a7ed352ae4a -->

- 2024-02-01 [How to Create a 'Next/Previous' Article Navigation in Nikola Static Site Generator](https://diegocarrasco.com/create-next-previous-navigation-nikola-ssg/)  _<svg xmlns="http://www.w3.org/2000/svg" x="5px" y="4px" width="15" height="15" viewbox="0,0,256,256" style="fill:#000000;">
<g fill="#ffffff" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><g transform="scale(5.12,5.12)"><path d="M25,2c-12.6907,0 -23,10.3093 -23,23c0,12.69071 10.3093,23 23,23c12.69071,0 23,-10.30929 23,-23c0,-12.6907 -10.30929,-23 -23,-23zM25,4c11.60982,0 21,9.39018 21,21c0,11.60982 -9.39018,21 -21,21c-11.60982,0 -21,-9.39018 -21,-21c0,-11.60982 9.39018,-21 21,-21zM37.03906,10.99023c-0.2941,-0.00848 -0.57702,0.11297 -0.77344,0.33203l-10.08203,10.92187c-0.37389,-0.16083 -0.77659,-0.24389 -1.18359,-0.24414c-1.65685,0 -3,1.34315 -3,3c0,1.65685 1.34315,3 3,3c0.16752,0.00031 0.33477,-0.01341 0.5,-0.04102l3.625,6.52734c0.17372,0.31266 0.50106,0.50888 0.85869,0.51473c0.35763,0.00585 0.69122,-0.17956 0.87507,-0.48637c0.18385,-0.30681 0.19004,-0.68841 0.01623,-1.00102l-3.62891,-6.5293c0.48474,-0.54747 0.75284,-1.25314 0.75391,-1.98437c-0.00023,-0.48813 -0.11957,-0.96883 -0.34766,-1.40039l10.08203,-10.92188c0.27102,-0.28603 0.34883,-0.70455 0.19871,-1.06887c-0.15012,-0.36433 -0.50017,-0.60655 -0.89402,-0.61863z"></path></g></g>
</svg> 4 min read.
- 2023-12-12 [Introducing my Custom Shortcodes for Nikola Static Site Generator](https://diegocarrasco.com/nikola-custom-shortcodes/)  _<svg xmlns="http://www.w3.org/2000/svg" x="5px" y="4px" width="15" height="15" viewbox="0,0,256,256" style="fill:#000000;">
<g fill="#ffffff" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><g transform="scale(5.12,5.12)"><path d="M25,2c-12.6907,0 -23,10.3093 -23,23c0,12.69071 10.3093,23 23,23c12.69071,0 23,-10.30929 23,-23c0,-12.6907 -10.30929,-23 -23,-23zM25,4c11.60982,0 21,9.39018 21,21c0,11.60982 -9.39018,21 -21,21c-11.60982,0 -21,-9.39018 -21,-21c0,-11.60982 9.39018,-21 21,-21zM37.03906,10.99023c-0.2941,-0.00848 -0.57702,0.11297 -0.77344,0.33203l-10.08203,10.92187c-0.37389,-0.16083 -0.77659,-0.24389 -1.18359,-0.24414c-1.65685,0 -3,1.34315 -3,3c0,1.65685 1.34315,3 3,3c0.16752,0.00031 0.33477,-0.01341 0.5,-0.04102l3.625,6.52734c0.17372,0.31266 0.50106,0.50888 0.85869,0.51473c0.35763,0.00585 0.69122,-0.17956 0.87507,-0.48637c0.18385,-0.30681 0.19004,-0.68841 0.01623,-1.00102l-3.62891,-6.5293c0.48474,-0.54747 0.75284,-1.25314 0.75391,-1.98437c-0.00023,-0.48813 -0.11957,-0.96883 -0.34766,-1.40039l10.08203,-10.92188c0.27102,-0.28603 0.34883,-0.70455 0.19871,-1.06887c-0.15012,-0.36433 -0.50017,-0.60655 -0.89402,-0.61863z"></path></g></g>
</svg> 3 min read.
- 2023-12-07 [How to Deploy a Nikola Static Site on Cloudflare Pages: A Step-by-Step Guide](https://diegocarrasco.com/deploy-nikola-site-cloudflare-pages/)  _<svg xmlns="http://www.w3.org/2000/svg" x="5px" y="4px" width="15" height="15" viewbox="0,0,256,256" style="fill:#000000;">
<g fill="#ffffff" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><g transform="scale(5.12,5.12)"><path d="M25,2c-12.6907,0 -23,10.3093 -23,23c0,12.69071 10.3093,23 23,23c12.69071,0 23,-10.30929 23,-23c0,-12.6907 -10.30929,-23 -23,-23zM25,4c11.60982,0 21,9.39018 21,21c0,11.60982 -9.39018,21 -21,21c-11.60982,0 -21,-9.39018 -21,-21c0,-11.60982 9.39018,-21 21,-21zM37.03906,10.99023c-0.2941,-0.00848 -0.57702,0.11297 -0.77344,0.33203l-10.08203,10.92187c-0.37389,-0.16083 -0.77659,-0.24389 -1.18359,-0.24414c-1.65685,0 -3,1.34315 -3,3c0,1.65685 1.34315,3 3,3c0.16752,0.00031 0.33477,-0.01341 0.5,-0.04102l3.625,6.52734c0.17372,0.31266 0.50106,0.50888 0.85869,0.51473c0.35763,0.00585 0.69122,-0.17956 0.87507,-0.48637c0.18385,-0.30681 0.19004,-0.68841 0.01623,-1.00102l-3.62891,-6.5293c0.48474,-0.54747 0.75284,-1.25314 0.75391,-1.98437c-0.00023,-0.48813 -0.11957,-0.96883 -0.34766,-1.40039l10.08203,-10.92188c0.27102,-0.28603 0.34883,-0.70455 0.19871,-1.06887c-0.15012,-0.36433 -0.50017,-0.60655 -0.89402,-0.61863z"></path></g></g>
</svg> 5 min read.
- 2022-12-29 [How to add a table of contents (TOC) to a markdown post or page to nikola ssg](https://diegocarrasco.com/how-to-add-a-table-of-contents-toc-to-a-markdown-post-or-page-to-nikola-ssg/)  _<svg xmlns="http://www.w3.org/2000/svg" x="5px" y="4px" width="15" height="15" viewbox="0,0,256,256" style="fill:#000000;">
<g fill="#ffffff" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><g transform="scale(5.12,5.12)"><path d="M25,2c-12.6907,0 -23,10.3093 -23,23c0,12.69071 10.3093,23 23,23c12.69071,0 23,-10.30929 23,-23c0,-12.6907 -10.30929,-23 -23,-23zM25,4c11.60982,0 21,9.39018 21,21c0,11.60982 -9.39018,21 -21,21c-11.60982,0 -21,-9.39018 -21,-21c0,-11.60982 9.39018,-21 21,-21zM37.03906,10.99023c-0.2941,-0.00848 -0.57702,0.11297 -0.77344,0.33203l-10.08203,10.92187c-0.37389,-0.16083 -0.77659,-0.24389 -1.18359,-0.24414c-1.65685,0 -3,1.34315 -3,3c0,1.65685 1.34315,3 3,3c0.16752,0.00031 0.33477,-0.01341 0.5,-0.04102l3.625,6.52734c0.17372,0.31266 0.50106,0.50888 0.85869,0.51473c0.35763,0.00585 0.69122,-0.17956 0.87507,-0.48637c0.18385,-0.30681 0.19004,-0.68841 0.01623,-1.00102l-3.62891,-6.5293c0.48474,-0.54747 0.75284,-1.25314 0.75391,-1.98437c-0.00023,-0.48813 -0.11957,-0.96883 -0.34766,-1.40039l10.08203,-10.92188c0.27102,-0.28603 0.34883,-0.70455 0.19871,-1.06887c-0.15012,-0.36433 -0.50017,-0.60655 -0.89402,-0.61863z"></path></g></g>
</svg> 1 min read.