'I THINK I would like to be able to set parameter defaults for a thing at the:
section+type
and
type
levels
and then be able to perform a dynamic lookup from a partial template which could be included from multiple depth hierarchies
and have the partial be able to grab the most relevant config value for the context in question’
Now, I’ll concede that it is ENTIRELY POSSIBLE (if not likely) that this isn’t that great an idea …because reasons I don’t yet understand…
but it seems like this would follow the established hierarchy of template lookups,
Does my question make sense?
assuming I’ve managed to convey the question grokably…
is this
already possible, and thoroughly documented, and I’m just dense?
already possible, but not terribly well documented, because it’s kinda not the greatest idea.
not currently possible, might be a good idea but not a priority to implement?
a terrible idea?
TIA y’all.
Thanks for being such a great community of helpful peeps.
With all the crap going on in the world around us, it’s legitimately refreshing to see such vibrant, helpful communities thriving.
content/
├── posts/
│ ├── section/
│ │ ├── _index.md <-- cascade color to all pages in section
│ │ ├── bar.md <-- set color for this page
│ │ └── foo.md <-- set color for this page
│ ├── _index.md <-- cascade color to all pages of this type
│ └── post-1.md <-- set color for this page
└── _index.md
Then in template call:
{{ .Param "color" }}
Precedence:
Page
Section
Type
Site default
Example:
git clone --single-branch -b hugo-forum-topic-47385 https://github.com/jmooring/hugo-testing hugo-forum-topic-47385
cd hugo-forum-topic-47385
hugo server
You can also define your “cascades” in site configuration, using cascade.target to target by path.
Sorry, I misunderstood. You want the inverse of a cascade, meaning that a content creator cannot override a site/type/section parameter at the page level.
If this is for yourself I suppose that’s fine, but I wouldn’t create a theme with this behavior because it is unexpected.
If you want to go top-down instead of bottom-up, you could use site.Params falling back to site.GetPage.
in this bit of … insanity…
the layoutarticles and the typelist are hardcoded.
I was hoping for a way to express them as variables and have the site params object searched with the layout and type relelvant to the page/construct being generated in their place.
does that make more sense?
(is there a better way I should have expressed this question so as to be more easily grokable?)
Both are accessible via page methods. Page.Type returns the .Type, regardless of whether inferred from top-level section or defined in front matter. .Page.Layout returns the layout defined in front matter (if any), otherwise returns an empty string.
layout is a refined semantical descriptor / label for Kind, right?
(It does make a lot more sense to me, type/kind were always getting mixed up in my head… layout is indeed more intuitively associative to the construct imo.)
or am I getting things even MORE muddled in my head again?
this is wot I meant by “associated based on its’ location in the hierarchy”
the _index.md page within a first-level subdir of content ( books/ in the example here) will have a kind value of section
and the template used to render that page’s content would be a list or a section template
the book-2.md file would have the kind page and would default to a single template…
if the directory matches a taxonomy key name specified in the taxonomies config file, then that page will have a kind value of taxonomy and would default to a list template for rendering…
however, if specified in front matter, layout will override the default template association, yes?
IOW: layout is a handle to more explicitly declare the rendering template of a given bit of content… (but doesn’t change the underlying page’s Kind)