How to change the path of the homepage?

Hi community,

I’d like to have the homepage of my blog lay at /blog/index.html, while having all the slugs starts at /. I first started using domain.tld/blog as site domain in the config.toml, but that led me to have /blog/section/post for the posts URLs, which is not what I’m looking for.
So I removed that, and now the homepage lies at /index.html.

Then my question is whether I can create a /blog/index.html page that will list all posts exactly like the homepage would do, and how can I do that? Simply said, a site tree like the following:

  • domain.tld/index.htmldomain.tld/blog/index.html for the homepage
  • domain.tld/<SECTION> for the sections
  • domain.tld/<SECTION>/<POST>/ for the posts

I have looked through the discuss forum and found a few questions that were close:

① adding a /layouts/_default/blog/list.html

bot all those solutions are based on the fact that all my blog posts are in the /blog section. So that would lead me to a tree like:

  • domain.tld/blog/index.html
  • domain.tld/blog/<SECTION>/
  • domain.tld/blog/<SECTION>/<POST>

which is not what I’m looking for…

where it redirects to an interesting tutorial, but still it’s not answering my usecase. There it tells how to create other pages that offer content (like about page} not a simple copy of /index.html in another path.

I’m still rather new to the way hugo works, and even though everything went very smoothly in converting my blog, that last bit, which I thought would be quite trivial, has been hurting me for a while now…


Following up on ①, I eventually hacked it so it list.html renders .Site.Pages, but to have the /blog section visible, I need to create a content entry within it, adding a bogus entry in the Pages…
I guess I could use a where filter on .Site.Pages to make that bogus post invisible, but it feels really hackish and dirty to have a bogus page that will still be published, even if not referenced by the listings…

So the currently hacked solution is as follows:

  • index.html contains a meta-refresh to /blog
  • content/blog/ contains post: ignore in the yaml
  • layouts/blog/list.html contains:
{{ partial "header" . }}
<div class="container clearfix">
    <main role="main" class="content">
        {{ $paginator := .Paginate (where .Site.Pages "Type" "!=" "ignore") }}
        {{ range $paginator.Pages }}
            {{ .Render "summary" }}
        {{ end }}
        {{ partial "pagination" . }}

    {{ partial "author" . }}
{{ partial "footer" . }}

and the generated output creates:

  • /blog/bogus/index.html that contains no content…

there should be a better, cleaner way to achieve something like that!