Section index (posts/) -vs- permalink (blog/:title)


I currently have a /posts/ Section, which is generating an index list of posts at /posts/index.html.

I set the posts permalink to be blog/:title, and my blog posts are now generated at /blog/post-title/index.html.

So far, so good-ish.

I noticed there is not an index generated at /blog/index.html, and it’s just weird to keep an index at /posts/, when my blog posts won’t live there.

I understand that this behavior makes sense, based on my limited configuration.

My desire is to have my blog posts index live at /blog/index.html, and my blog posts show up as they do, with the permalink change. But I like putting my posts in /content/posts/.

Is this possible, and what should I be looking to change/configure?

(I am a web developer, not new to the concepts, just new to Go + Hugo)

These are list pages, listing posts. That is important to understand when emulating that template behavior elsewhere.

You know the easiest way to do it is to just move posts to blog, because then /blog/ is a section, and loads the correct template.

So in your case you need to create a layout template, or shortcode, and add a static page at that URL. Pagination is going to make it complicated, as well. But those are the components of Hugo that you will use.

Another option is to redirect /blog/ to /posts/. Does it really matter to the person manually entering your partial URL address that it stay the same, if they get to the content they are expecting? :slight_smile:

So, I actually gave it a few minutes thought, and realized that I just needed to get over whatever stigma was in my head about wanting to store them in “posts”, and just changed it to storing the content in “blog”.

Haha. Silly me.

It just makes perfect sense, for all the sane defaults that are easier, and custom templates I don’t have to make – and doing it “right” is exactly what I would have advised anyone else to do. I was blinded from taking my own advice for a bit.



Almost every person that comes in here has some “need” to keep their system in a particular way, hence why I always open with the obvious, easy path, but explore alternatives none the less. :slight_smile:

My config has:

  posts = "/:year/:month/:slug/"

So I’ve considered your issue before. Do I want to list posts at /blog? How would I even set up yearly archives?

I’ve put those off for now, but I’ve experimented! I like listing posts by taxonomy term as a shortcode, a practice I’ve used for years in WordPress. This isn’t an uncommon use case, but yeah, the defaults are pretty good. :sunny:

Yes, your obvious suggestion was spot on.

Thanks for being gracious to an internet stranger, despite my initially crazy idea.

That speaks volumes of the Hugo community – at least my initial impressions of it here. =)

1 Like