cvh
November 28, 2018, 5:01pm
1
Hi!
I have a content folder structure like that:
It would be good if that is generated to the following URLs:
/latest-infos/
/latest-infos/info-1/
/latest-infos/info-2/
/older-infos/
/older-infos/info-a/
/older-infos/info-b/
Is there straight forward practice to achieve that? I had no luck with βpermalinksβ in config.yaml.
Thanks!
zwbetz
November 28, 2018, 5:26pm
2
Hereβs one way to accomplish this.
Given content structure like you mentioned:
content/
βββ section-1
βββ latest-infos
β βββ info-1
β β βββ index.md
β βββ info-2
β βββ index.md
βββ older-infos
βββ info-a
β βββ index.md
βββ info-b
βββ index.md
You could define a slug
front matter param in each index.md
file. For example:
---
title: "Info 1"
slug: /latest-infos/
---
Then in your config.yaml
:
permalinks:
section-1: /:slug/:title/
Then when building your site, the structure would be like:
public/
βββ latest-infos
β βββ info-1
β β βββ index.html
β βββ info-2
β βββ index.html
βββ older-infos
β βββ info-a
β β βββ index.html
β βββ info-b
β βββ index.html
1 Like
You could also try to use the url
parameter in the front matter of your nested sectionsβ _index.md
as well as in your content files.
e.g.
+++
url = "/latest-infos/"
+++
2 Likes
cvh
November 28, 2018, 11:41pm
4
Thanks for your help. I guess there is no solution without specifying something in every front matter?
regis
November 29, 2018, 12:07am
5
@zwbetz βs solution only involves the sectionsβ Front Matter though. Your pagesβ can remain unchanged.
cvh
November 29, 2018, 8:55am
6
Tried that but that doesnt work. @zwbetz also mentioned βin each index.md
fileβ.
zwbetz
November 29, 2018, 1:13pm
7
@cvh does your content look like this?
content/
βββ section-1
βββ latest-infos
β βββ info-1
β β βββ index.md
β βββ info-2
β βββ index.md
βββ older-infos
βββ info-a
β βββ index.md
βββ info-b
βββ index.md
cvh
November 29, 2018, 1:19pm
8
@zwbetz Yes. There are also _index.md
in latest-infos
and older-infos
. But that shouldnβt make a difference, right?.
zwbetz
November 29, 2018, 1:26pm
9
Hmm, it works fine on my end.
Youβve added the permalink setting to your config file?
ju52
November 29, 2018, 3:00pm
10
use archetypes!
slug: /latest-infos/
will be copied from archetype to content file!
1 Like
cvh
November 30, 2018, 8:26am
11
If I specify the slug in every index.md it works. Would be nice to have it specified only at one place
cvh
November 30, 2018, 8:27am
12
Yes, thanks. Good idea. But if i want to change it later, I have to replace it in every file (still better than to specify slug always manually, no doubt).
zwbetz
November 30, 2018, 1:13pm
13
Text editors these days (vscode, atom, etc.) make find-n-replace like that easy
1 Like
cvh
November 30, 2018, 9:03pm
14
Yes you are right. Iβll take this approach. Thank you all for your quick help!