Two home pages


In my theme, I want to create a second add-on page with a feed of posts, in which posts will be sorted by update date, or any other parameter. Can this be done somehow?

There can only be one home page at the root of your site, unless you made the site dynamic (i.e. non-Hugo) and changed it depending on certain conditions, like the presence of particular data in a cookie.

You can add other pages that will give different ‘views’ on your content. Add a page called and add layout: "datesort" to the frontmatter (if you are using YAML). Then create a datesort.html layout template in the layout folder that sorts according to how you want it to be sorted. That’s the hard part.

Then add a link from your home page to this page.


Thanks for the advice, but I didn’t fully understand what needs to be done ((

I created a folder called ‘better’ in the ‘content’ folder and put in it. It indicated: layout: “better”.

In the template itself, I added a better folder to the layouts folder and index.html to it.

But nothing worked. Yes, the page / better appeared, but there is a wrong template

The template under layouts/better/index.html is meant for a Section list page.

Yet you have /content/better/ which is a Single Page controlled by /layouts/better/single.html

You need to either rename the template to single.html or if /better/ is meant to list more content files you need to change the to so that you get a published Section and not a Single Page.

See the template lookup order for Page Kinds:

I renamed to and in the end it didn’t help. Yes, the template has changed. Layouts / _default / section.html is now used instead of single, but not layouts / better / index.html

We cannot know what is your setup without seeing the full context.

See the Requesting Help guidelines and provide a minimal repo that reproduces your issue.

However I am terribly busy at the moment and I’ve no time for support in this forum.

Perhaps someone else can look into it, if you provide a repo.

Perhaps I did not describe my problem correctly.

I do not need a separate topic for the section, these are the tips that you seem to be giving me. I need to create two pages similar to /layouts/index.html with different sorting approaches.

Thus, I want to get the main page and an alternative main page, for example, which will have the same posts as on the main page. But on the main page they will be sorted by creation date, and on / better by modified date.

That is, if you cannot sort content on the fly due to the limitations of static sites, I would like to provide users with two or more alternative sorts in advance. On the main page by the date it was added, and on the alternative by the date it was updated

Content structure:

├── better
│   └──
├── post
│   ├──
│   ├──
│   └──


title = "Better"
date = 2021-03-04T17:02:42-08:00
draft = false
type = "post"
layout = "posts-by-lastmod"

Template structure:

├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
├── post
│   └── posts-by-lastmod.html
└── index.html


{{ define "main" }}
  {{ .Content }}
  {{ range (where .Site.RegularPages "Type" "post").ByLastmod.Reverse }}
    <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
  {{ end }}
{{ end }}


{{ define "main" }}
  {{ .Content }}
  {{ range (where .Site.RegularPages "Type" "post").ByDate.Reverse }}
    <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
  {{ end }}
{{ end }}

config.toml (see

enableGitInfo = true

@jmooring’s answer is great, and I think it should have solved your problem.
I add a few links that I think might be useful to you, as follows:


  1. Lists of Content in Hugo
    • By Date
    • By Publish Date
    • By Last Modified Date
    • By Weight
  2. Related Content


Here are some examples of what I have done on my own site




output result

This is a great answer and it works for me.

But I would like to clarify if it is possible to somehow embed it in the template so that template users do not need to create an md file.

I don’t understand your question.

@jmoorings not the OP but jmoorings answer was super helpful. Was playing around with something similar on a site I’m testing. Thanks for sharing!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.