Cascade frontmatter to all languages

Is there a way of defining a single file to hold frontmatter which should cascade to all languages?

Currently, I have some variation of the following in all of the _index.{lang}.md files in a folder:

---
title: Categories
cascade:
  - _target:
      kind: term
    supTitle: Category
  - heroClass: bg-light-01
    theme: extra-light
---

Folder structure

├── ./content/category
├── _index.en.md
├── _index.sv.md
├── _index.vi.md
├── _index.zh.md
├── category-one
│  └── _index.md
├── category-two
│  └── _index.md
└── category-three
   └── _index.md

Much of that is redundant, though. Is there a way of including a _index.md (no lang suffix) with cascaded frontmatter?

Define the cascade in your site configuration.

1 Like

Forgive my ignorance, but if defined there, how do I limit to the content/category section?

EDIT

Would this be the recommended way?

[params]
  [[cascade]]
    heroClass = "bg-light-01"
    theme = "extra-light"
    [cascade._target]
      kind = "{taxonomy,term}"

https://gohugo.io/content-management/front-matter#target-specific-pages

2 Likes

Follow up:

Do you know why the following wouldn’t work? Expected result is that the last block would override the previous for the specified languages:

[[cascade]]
  render = false
  [cascade._target]
    kind = "{taxonomy}"

[[cascade]]
  render = true
  [cascade._target]
    lang = "{en,es}"
    kind = "{taxonomy}"

You cannot use cascade to override a value set in front matter (front matter takes precedence). In the same way, I would expect the first array element to take precedence.

Ahh, interesting. I was working off the assumption that the last item would win. This is helpful, though. Thank you!

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