Skip to content

Add inherit_metadata setting for translated pages - #3239

Open
bemyak wants to merge 1 commit into
getzola:nextfrom
bemyak:metadata-inheritance
Open

Add inherit_metadata setting for translated pages#3239
bemyak wants to merge 1 commit into
getzola:nextfrom
bemyak:metadata-inheritance

Conversation

@bemyak

@bemyak bemyak commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR implements #3204

There were two ways of doing this:

  1. Implement merging for already parsed pages. This would require making fields of PageFrontMatter into Optionals, which users can observe in serialized template. Also, the merge function must be updated every time a new field is added to PageFrontMatter. Empty arrays become indistinguishable from absent (e.g. for authors = []). Meh.
  2. Merge the front matter after TOML parsing, but before being parsed as a page. This is much less impactful way, which I chose here. The drawback is that pages now need to carry the raw frontmatter.

The performance impact for an average size frontmatter (~10 fields) seems to be 45ms for 500 pages, so <1ms per page, part of which is newly rendered taxonomy pages. This is paid only when the feature is enabled, no change by default.

Sanity check
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?
  • Was a LLM used? If so, for what? Yes, for writing tests, performing benchmarks and pondering ideas about feature integration, help with iterating over the code. I understand the submitted changes.

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

When enabled, a translated page inherits the front-matter fields it
omits from the default-language page. Tables merge per key and the
translation wins conflicts; arrays and scalars replace inherited
values. slug, path and aliases are never inherited. Taxonomy names
that the translation's language doesn't define are dropped when
inherited.

Enabled site-wide with inherit_metadata = true in config.toml, or per
section with the same key in _index.md and _index.{lang}.md; the
closest section setting wins, preferring the page's own language.

Closes getzola#3204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant