Skip to main content

Front matter post-processor for static site generators

Project description


Dry Run Build PyPI version

Front matter post-processor for static site generators.


Prelims eases updating YAML front matter of the static site generator contents (e.g., Hugo, Jekyll, Hexo).

You can extract keywords based on TF-IDF weighting, generate a list of recommended posts by content-based filtering, and even apply arbitrary custom functions to update front matters on-the-fly.


Below is an original front matter for "User-Centricity Matters: My Reading List from RecSys 2021" at

categories: [Recommender Systems]
date: 2021-10-05
lang: en
title: 'User-Centricity Matters: My Reading List from RecSys 2021'

Once a Python script is executed against all the posts, new metadata recommendations and keywords are dynamically generated and inserted as:

categories: [Recommender Systems]
date: 2021-10-05
keywords: [recsys, bias, papers, wordcloud, echo, user, recommendations, metrics,
  recommender, users]
lang: en
recommendations: [/note/recsys-2021-echo-chambers-and-filter-bubbles/, /note/recsys-wordcloud/,
title: 'User-Centricity Matters: My Reading List from RecSys 2021'


$ pip install prelims


Assume your posts are under /path/to/posts where a static site generator uses as a document root:

├── ...

Here, the following script reads all .md and .html files in the folder, builds recommendations, and update each post's front matter:

from prelims import StaticSitePostsHandler
from prelims.processor import Recommender

handler = StaticSitePostsHandler('/path/to/posts')

For instance, a front matter of may eventually become:

date: 2022-01-01
title: Awesome Blog Post
recommendations: [/post/article-zzz/, /post/article-abc/, /post/article-xyz/]
keywords: [happy, beer, coffee, park, ...]

You can run the script as a pre-commit hook and automate the process e.g., with lint-staged:

$ npm install -D lint-staged
  "lint-staged": {
    "posts/*.{md,html}": [
      "python ./scripts/",
      "git add -u posts/"


  • The author is testing and using Prelims mainly with Hugo. Although the tool is intended to be applicable to a variety of static site generators, there must be several edge cases that won't work properly due to unique behaviors associated with a specific generator.
  • We assume there are hundreds of posts at most, not thousands. Every single post is sequentially processed one-by-one, and the Recommender module, for example, trains a model from scratch every time. As the number of posts increases, you may encounter scalability issues.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prelims-0.0.7.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

prelims-0.0.7-py3-none-any.whl (10.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page