Hi. Iβm quite new to hugo.
I know we have list.html and single.html inside _default, and we can set a custom single.html using different folder.
My question is, if let said i have three products, all the data in three seperate .yml, which the three will use the products/list.html to list the three items.
how do i create a custom page for the three item? like having 3 single.html file, each unique to one items? Do i need to use layout?
Instead of storing data as data files, store them in content/products/product-*/index.md as frontmatter. Then you can specify the layout you want to use through the layout frontmatter variable.
Define the custom layout in layouts folder and youβll be good to go.
I have already define a custom .html file in
layouts/products/productA.html
layouts/products/productB.html
layouts/products/productC.html
what should i put in the content/products/_index.md to tell the which page should use which page, and not to use the layouts/products/single.html?
When you mention specify the layout frontmatter variable, does that mean each .html should check if the variable equal to βAβ, something like that?
did you mean in the layout/product/single.html, i should have a code to check the frontmmatter that i declare in content/product/productA.md? for example
author: testing
layout: contentA
then use the frontmatter βlayoutβ to be check inside single.html?
or do you means inside the content/product/_index.md, i should declare βkind/layoutβ variable, and then it will somehow know which content should use which html?
git clone --single-branch -b hugo-forum-topic-37085 https://github.com/jmooring/hugo-testing hugo-forum-topic-37085
cd hugo-forum-topic-37085
hugo server
content/
βββ products/
β βββ _index.md
β βββ product-1.md <-- front matter: layout = 'product-1'
β βββ product-2.md <-- front matter: layout = 'product-2
β βββ product-3.md <-- front matter: layout = 'product-3'
β βββ product-4.md
βββ _index.md
layouts/
βββ _default/
β βββ baseof.html
β βββ home.html
β βββ list.html
β βββ single.html
βββ products/
βββ list.html <-- used by content/products/_index.md
βββ product-1.html <-- used by content/products/product-1.md
βββ product-2.html <-- used by content/products/product-2.md
βββ product-3.html <-- used by content/products/product-3.md
βββ single.html <-- used by content/products/product-4.md
wow thanks man!! Now I understand how to use the layout frontmatter. I though need by βsetβ means i need to set it to true, or others.
THanks for your example as well!!