-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow cascading Front Matter #6041
Comments
Sounds like a good idea. About the naming, how about The name implies that all the parameters under |
I like this very much, and as long as we restrict the I think this should be able to solve some other long-standing issues:
It does not solve (my) primary motivation behind # #5455 -- which I vaguely remember as a way to batch-reorder pages (by setting |
I’m glad you guys are on board. @kaushalmodi, I’ll never get bored of discussing parameter names with you :) I think such a feature should be called Cascading Front Matter because I believe everyone will instantly understand what this does just by reading those 3 words. Hence using cascade as parameter. But it’s also safer than I would suspect someone somewhere is already using defaults in their front matter. Also defaults are temporary values to be overwritten. Here they will rarely be (I suspect). |
Fixes gohugoio#6041 Fixes gohugoio#6153 Fixes gohugoio#6154
Fixes gohugoio#6041 Fixes gohugoio#6153 Fixes gohugoio#6154
Fixes gohugoio#6041 Fixes gohugoio#6153 Fixes gohugoio#6154
Fixes gohugoio#6041 Fixes gohugoio#6153 Fixes gohugoio#6154
This is preparation for gohugoio#6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: Fixes gohugoio#6154 Fixes gohugoio#6153 Fixes gohugoio#6152
This is preparation for gohugoio#6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: Fixes gohugoio#6154 Fixes gohugoio#6153 Fixes gohugoio#6152
This is preparation for gohugoio#6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: Fixes gohugoio#6154 Fixes gohugoio#6153 Fixes gohugoio#6152
This is preparation for gohugoio#6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: Fixes gohugoio#6154 Fixes gohugoio#6153 Fixes gohugoio#6152
This is preparation for gohugoio#6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: This commit also switches the radix tree dependency to a mutable implementation: github.com/armon/go-radix. Fixes gohugoio#6154 Fixes gohugoio#6153 Fixes gohugoio#6152
This is preparation for gohugoio#6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: This commit also switches the radix tree dependency to a mutable implementation: github.com/armon/go-radix. Fixes gohugoio#6154 Fixes gohugoio#6153 Fixes gohugoio#6152
This is preparation for #6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: This commit also switches the radix tree dependency to a mutable implementation: github.com/armon/go-radix. Fixes #6154 Fixes #6153 Fixes #6152
@regisphilibert a quick yes and no question to verify that we're in line here: The values defined in |
Yes I saw My turn:
Does this mean we cannot use the homepage to define "global" cascade for all pages? If not, maybe global |
You can, but it will not apply to the home page itself (we could of course decide to make an exception for the home page, which I guess would make sense). I have a related question that, while testing this, surprised me a little. But I guess it is how it is going to be. If you say for cascade:
outputs: [HTML] It means that you want all the ancestors to output HTML only (unless overridden by front matter or another cascade). But then you somewhere in the tree do something like this for cascade:
icon: "flag.png" So, by adding the cascade with that I don't think we can ... cascade (or merge) the cascades, so to speak. Or, not as the default behaviour. We can maybe add a |
I thought they would merge. I really see this as a parallel to CSS (and other) cascading mechanism. Everything from the ancestors' tree is kept unless overwritten. If ultimately this is not possible, this will still be a very useful feature but maybe with a different name though. |
OK, let's do that. There are maybe some potential issues with that, too, but probably less confusing than the other variant.
You would then maybe typically end up with something like this for a section: title: "My Section
icon: "flag.png"
outputs: ["HTML"]
type: "blog"
cascade:
icon: "flag.png"
outputs: ["HTML"]
type: "blog" Which I guess is fine? |
But not great I suppose. If we go back to the CSS comparison, It seems okay in this context that a regular FM would overwrite the section's To use your example: title: "My Section"
icon: "world.png"
cascade:
icon: "flag.png"
outputs: ["HTML"]
type: "blog" The section would send down the cascade the Again, route A is fine as well, but will lead to more copy/paste than B I think. |
I'm not sure I'm totally getting the CSS allegory, but both B and my initial question about "to merge the cascades" or not have the same problem in that it's not possible to delete elements set in the cascade, you need to somehow set a zero value, e.g.: title: "My Section"
icon: "" # I don't want an icon
cascade:
icon: "flag.png"
outputs: ["HTML"]
type: "blog" And similar: title: "My Section"
icon: "flag.png"
cascade:
icon: "" # I don't want my ancestors to have an icon.
outputs: ["HTML"]
type: "blog" But the above avoids the most copy/paste and I suspect is the least surprising. So I suggest:
|
Yes as mentioned in this issue's desc, for me it is a good trade of. And I gladly welcome both your conclusions, route B and merge. |
This is a really helpful feature, thank you so @regisphilibert! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This issue adresses batch assignment of Front Matter values to descendants of any given content file and is inspired to some extend by the data assignment logic of https://github.com/11ty/eleventy.
Batch assign is already addressed here #5455 but from a single entry point.
I think the following could complement the above for many use cases and provide a simpler approach to batch assign.
Here, we would simply create a new reserved key in Front Matter underneath which any number of key/value pair could be cascaded through the page’s descendants.
Consider the following structure and content files' Front Matter:
Looking at the different content files above, and from within the template files,
.Params.banner
would output the following:/contact.md
windows-bliss.jpg
/blog/moving-again.md
typewriter.jpg
/blog/san-fransisco-series/presidio.md
golden-gate-sunset
/blog/san-fransisco-series/castro.md
golden-gate-sunset
/blog/san-fransisco-series/lombard.md
herbie-lombard.jpg
Repercusions
They're safe as those "special" key/value pair would be stored in a reserved map.
On the other hand this could take care of #5652 and potentially other issues not yet identified.
How to overwrite with an empty value?
What if a page does not want a banner?
It becomes the user responsibility to allow an empty or boolean overwrite to editors. I think it's a fair trade-off.
Data source
This for now does not solve the problem of batch assigning Front Matter to remote content, but it could if the user can create a content file matching the remote’s content section and store the section’s Front Matter (cascading or not) in there.
The text was updated successfully, but these errors were encountered: