Tealk
February 2, 2023, 8:40pm
1
Hello,
i would like to show the date of the post for certain slugs, but unfortunately this only works for the first slug. for terms, imprint and privacy the following code does not work.
{{ if (or (eq .Slug "charta") (eq .Slug "terms") (eq .Slug "imprint") (eq .Slug "privacy")) }}
<div class="meta text-end">
<span title="Veröffentlicht"><i class="fas fa-calendar-alt"></i> {{ .Date | time.Format ":date_long" }}</span>
<span title="Modifiziert"><i class="fas fa-history"></i> {{ .Lastmod | time.Format ":date_long" }}</span>
</div>
{{ end }}
Did you set the slug
in front matter for each of the four pages? I’m assuming your content looks like:
content/
├── charta.md
├── imprint.md
├── privacy.md
├── terms.md
└── _index.md
Tealk
February 2, 2023, 8:56pm
3
charta
is not a regular page; it is a section, so it uses
themes/rm/layouts/_default/list.html
The other three pages are regular pages, so they use
themes/rm/layouts/_default/single.html
This template does not contain your date code.
1 Like
Tealk
February 2, 2023, 9:04pm
5
Thank you, of course you are absolutely right, if I adapt the wrong template it can not work.
1 Like
system
Closed
February 4, 2023, 9:04pm
6
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.