Reputation: 1508
According to Jekyll Docs, you can add categories to the permalink like so: /:categories
, but what if I want to use front matter that isn't categories? For example, I have a front matter named state
. I tried adding /:state
to no avail.
For example: state/:state
is my permalink. In my front matter I have the following:
---
state: tx
---
So then my url will be state/tx
.
I realize that I can create a custom permalink in the front matter of each page, but I am looking for something automatic as I am having less savvy users update the site. Also, categories
isn't an obvious indicator that a state abbreviation should go there for my content managers.
Upvotes: 1
Views: 950
Reputation: 1791
as you may have already noticed. using a default front matter for states' page can achieve that. can achieve the automatic permalink generation.
by adding the following to _config.yml
:
defaults:
-
scope:
path: "_states" # states' page location
values:
permalink: /state/:categories/:slug/
and in each page, using a yaml front matter like:
---
category: tx
---
But if you want to get ride of the "category" here, and you can use local plaguing with your website (for example github page doesn't support them by default) then add a generator that run before the site is generated, looks for the state
value from the yaml front mater of each page, and put it in the appropriate folder.
Upvotes: 3
Reputation: 23942
That "act as a placeholder", you won't see /:categories in your URLs, it says that if a post you made belonging to a category, the name of the post category will go there.
For example: having a post with the following front matter :
---
categories: mycat
---
Then that post URL will start with /mycat/....
If you want custom variables included in the front matter to be replaced in perm a links, that can't be done. You can just add custom strings to the permalinks but not variables.
Upvotes: 0