Modify Permalink Structure of Jekyll Theme Minimal Mistakes

Oct. 21, 2023

My blog website is based on a Jekyll theme minimal-mistake1. Under default settings, the permalink of a blog page is composite of categories key and the file name of corresponding .md file. For example, if I write a .md file named 2023-10-21-This-is-a-Test-File-(md-file-Name).md, and whose content is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
---
layout: single
title: This is a Test File
date: 2023-10-21 16:42:58 +0800
categories:
 - Test Category 1
 - Test Category 2
tag: 
 - Test Tag 1
 - Test Tag 2
toc: false
---

This is content of test file.

After I post it, the corresponding website is like:

image-20231021173501798

As can be seen, the permalink is determined by categories key in YAML language area and the text after date in .md file name. And the website breadcrumbs are determined by categories and title key in YAML area.

However, during the process of managing website contents, I find this permalink structure is kind of fragile, cause sometimes I would modify the categories of the blog and the .md file name, which makes the previous permalink is not available any more. So, I want to find a more unique permalink structure.

Actually, the permalink structure setting could be found in _config.yml file:

image-20231021163250999

We could change it to:

1
permalink: /:year-:month-:day/:hour-:minute-:second:output_ext

N.B., References23 give detailed information about how to specify this setting.

making date and time stamp construct permalink:

image-20231021184024468

However, it shows that the Jekyll will resolve the content between the first and the second slash in permalink as a category, which is out of expectation.

When I click 2023 10 21 in breadcrumbs, the website will jump to categories.html, but we could find that it doesn’t create a real category:

image-20231021184842941

On another hand, if we set permalink structure like:

1
permalink: /:year-:month-:day-:hour-:minute-:second:output_ext

that is don’t use slash to separate date and time, the permalink and breadcrumbs will show like this:

image-20231021185305180

At this case, the breadcrumbs look useless.

I tend to use slash to make a separation, so I decide to delete breadcrumbs: open .\layouts\single.html and comment the following code:

image-20231021190437416

Added on Oct. 27, 2023: Actually, the breadcrumbs function could be closed by specifying breadcrumbs key in _config.yml to false, instead of commenting above code, the details could be found in4.

The final effect is:

image-20231021191203945

not bad anyway ~


References