Filter/flag content for homepage

Just trying to wrap my head around this. I want to flag specific content from a /Work section of my hugo site, to display on the homepage in a specific order.

For context, I’m making a photography portfolio, and /Work will have multiple sections with content. The index.html/homepage would be a feed of selected singles/posts and I’d like to be able to control the order they are displayed/rendered.

Any suggestions on how to best tackle that are much appreciated. Or ideas to do it differently. I could always just make the homepage custom/html. But I’d love to have some sort of control over making changes as content is added.


1 Like

In the front matter of the pages you wish to display on the home page:

title = "Foo"
date = 2020-07-06T11:26:53-04:00
draft = false
home_page_weight = 10

Then, in layouts/index.html:

{{ range where (.Site.RegularPages.ByParam "home_page_weight") "Params.home_page_weight" "ne" nil }}


  1. If home_page_weight is not set, the page will not be listed.
  2. The home_page_weight can be any number (positive, negative, or zero). Lighter values will float to the top of the list, while heavier numbers will sink to the bottom.
  3. The example front matter is TOML.
1 Like

Interesting. Originally I was looking for a way to order by weight in the front matter but came up short in google/docs.

Will give that a whirl!