Add inherit_metadata setting for translated pages - #3239
Open
bemyak wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements #3204
There were two ways of doing this:
PageFrontMatterinto 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. forauthors = []). Meh.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
Code changes
(Delete or ignore this section for documentation changes)
nextbranch?If the change is a new feature or adding to/changing an existing one: