Check multiple slugs

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

Yes I set the slug in the front matter. The structure can be seen here: RollenspielMonster/website: Quellcode der Webseite (created with https://gohugo.io) - website - Codeberg.org

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

Thank you, of course you are absolutely right, if I adapt the wrong template it can not work.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.