Install multiple categories in jekyll

I have a markdown file as follows:

--- title: My Page categories: - first - second --- 

In my _config.yml file, I set the link constant /:categories/:title.html

Therefore, when I create the site, the permalink ends as /first/second/title.html, while I was hoping that Jekyll would create /first/title.html and / second / title.html

Is there any way to do this without custom plugins?

Greetings

+5
source share
2 answers

According to these documents , it looks like there can only be one category on each Jekyll page. categories is wrong because you really define a "category hierarchy" - as a file path - so the message is really in one (sub) category. In this limited sense, you cannot do what you want with Jekyll vanilla.

However, Jekyll will process files simply sitting in any directory that does not begin with underscores, and it follows symbolic links. For example, if you create directories for each category and place your page in one of them, you can create symbolic links for any number of other "categories".

 mkdir first second touch first/page.md ln -s ../first/page.md second/ 
0
source

The easiest and best way is to define a permalink through frontmatter. This is also great for search engine optimization. First you tell Jekyll via _config.yml how Jekyll should build links if you forget to install it through frontmatter:

_config.yml

 # Build settings permalink: /:categories/:title/ 

Define permalink ...

2014-10-17_my_post.md

 --- layout: post title: 'Post with permalink' permalink: /this-is-the-unique-permalink/ --- My Post 
+3
source

Source: https://habr.com/ru/post/1204854/


All Articles