CloudNative.Quest

Quest to Cloud Native Computing

Discuss about Pelican static site generator

Author:


Modified: Tue, 2021-Aug-24

What is SSG and Pelican?

SSG stands for static site generator. SSG is a software application that generates static pages. It usually generates static HTML pages from templates. Besides generating static pages, some SSG (usually Node.JS based SSG) also support SSR or server side rendering. But strictly speaking, SSR is not SSG, it is not serving pre-rendered HTML static pages.

There are lots of SSG in the market. Majority of them are JavaScript based, for example: Next.JS, Gatsby and Eleventy (11ty). For other programming languages, usually you will find one or two popular SSG, like Hugo (GoLang), Zola (Rust), Jekyll (Ruby) and Pelican (Python).

Pelican is a static site generator written in Python. Instead of writing HTML, writers write markup languages like MarkDown. Then the articles are feeded into the SSG. One of the advantage of Pelican is that it is very strong at meta data (categories, tags) about articles or blogs.

The SSG processes articles by using Jinja2 templates and transform them into HTML static pages. You could use pre-existing themes from other people. A theme defines how a web site looks like. Themes usually contain set of files including CSS style sheets, JavaScript for logic in client side browsers, background images, icons and the HTML templates. Pelican is the main program of generating static pages. If extra functionality like SEO is needed, you could install plugins. You could find lots of Pelican themes in here: Pelican themes in GitHub

Check out these themes, they are quite good:

You could also create your own theme or modify an existing theme.

Notes and Tips about Pelican

The official installation guide provides detail instructions on how to install Pelican. Here I would like to provide a few tips about Pelican

  1. Pelican version 4.6.0 does not support Pygments 2.9.0. Install Pygments 2.8.1 instead.

  2. If you do not need to generate static pages per author (it would make duplicate pages in the web site), you can configure these parameters:

            AUTHORS_SAVE_AS = ''
    AUTHOR_URL = ''
    AUTHOR_SAVE_AS = ''
  3. If you do not want Pelican to generate any tags related page, use this parameters:

            TAGS_SAVE_AS = ''
    TAG_SAVE_AS = ''
  4. Be sure to check out the plugins for Pelican

  5. Finally, check out the Pelican documentation and FAQ.

Conclusion

Pelican, Jekyll, Eleventy (11ty) and etc. are the same type of SSG. They generate static HTML based on templates. If the web site does not use lots of client side JavaScript, it would be fine. If the web site is using Web Components and it needs to load lots of JavaScripts without selecting the ones it needed (without tree shaking), then it would affect performance. Many JavaScript based SSG support tree shaking by using programs similar to Rollup or Webpack. Finally, using SSG like Pelican and Jekyll would make it difficult to use web framework like React or Vue. For Vue, the developers could load the whole UMD JavaScript to use it (performance impacted). The developers could also use ES module and select the modules they needed. If the SSG does not have native support or having plugins for tree shaking, it would be cumbersome or non-convenient.

Finally, I would suggest take a look about Svelte. Svelte itself is a front end framework in JavaScript, it would have it’s own programming syntax. By utilizing SSG on Svelte like SvelteKit, in beta or Sapper, not actively developed anymore, it could generate (or export) a static web site or serve web pages in SSR mode (server side rendering). For export mode, it could offload some of the JavaScript to be loaded or execute in client side by pre-rendering or during the transformation of static pages. Besides that, Svelte applications could use bundler like Vite or Snowpack for tree shaking. SvelteKit is not a fully matured product yet but it looks promising.


Share this article


Related articles



Twitter responses: 1


Comments

No. of comments: 0

This site uses Akismet and Google Perspective API to reduce spam and abuses.
Please read and agree the privacy policy before using the comment system.