List of all posts, located at custom URL

I’m migrating a Lektor-generated site to Hugo. On my current site I have a list of all posts, paginated like this:

https://emptysqua.re/blog/all-posts/
https://emptysqua.re/blog/all-posts/page/2/

… and so on.

Is it possible for Hugo to generate a list of all posts with a URL structure like this? I’d like to keep the existing URLs instead of redirecting to a new URL structure.

Yes, but you need to create a section (root folder) with the name all-posts. If this isn’t where you store your content, you have to create one dummy content file for that section to be created. You will then have to create a list template that lists all the content with a paginator.

Thanks, with your help I’ve got URLs like this working:

/all-posts/
/all-posts/page/2/

Here’s the commit where I implemented this section.

In order to match my existing site’s URLs, I need to move the “all-posts” section here:

/blog/all-posts/
/blog/all-posts/page/2/

I don’t know how to do that yet. I think I have the same question as https://discuss.gohugo.io/t/make-home-to-be-subdirectory/4345

Aha, I’m all fixed now. I’ve added to config.toml:

baseurl = "https://emptysqua.re/blog/"

and then moved my content into the root dir, and finally created a home page using the trick from this discussion:

  {{ range where .Data.Pages "Section" "home" }}
    {{ .Content}}
  {{ end }}