'Disable page nesting / content sections in Hugo and publish all pages at top-level?

It's been 5 years since I've last used Hugo, so there is a lot I am forgetting and perhaps some things have changed as well.

I use Hugo to publish a static blog, and for some reason everything is being published under a "Post" section that you have to click into, at which point the page is title "#Posts". I do not recall this ever happening before.

I tried using --disableKinds=section to successfully stop "Post" from showing up on my main page, but the children pages disappeared as well. In addition to wanting my blog posts to show up on my main page, I want the URL structure to reflect this corrected organization; i.e., right now everything is showing up under mywebsite.com/post/article-name-here when it should just be mywebsite.com/article-name-here.]

Within my repository, my blog articles are in fact stored under content/post/article-name-here, but when I moved my articles into the content directory directly, Hugo failed to display them.

I feel like this should be a very easy fix, but I'm clearly not using the right search terms to describe what is going on.

Please let me know what other information I can provide as I am having a hard time articulating what is going on.

Main Hugo page with incorrectly displayed "Posts" article that leads to my actual posts.

Articles I want to appear at my top-level URL.



Solution 1:[1]

Here is the temporary solution I worked out thanks to Mr. Hugo's answer above/below:

  • Set the permalink configuration in my config.toml file as Mr. Hugo noted.
  • Set url = "article-name-here" inside every blog post's Markdown file.
  • Publish using hugo via command line, take the index.html and index.xml files within the publish/post directory, and move them into the publish directory (i.e., overwrite the index.html and index.xml files already there).
  • Manually retitle the content of the h1 tag inside index.html from "#Posts" to "Recent Articles".

Hopefully I can figure out a better answer and update this Stack Overflow question once I do.

Solution 2:[2]

Setting the permalink

right now everything is showing up under mywebsite.com/post/article-name-here when it should just be mywebsite.com/article-name-here

When you are using a config.yaml file, you can add this to it:

permalinks: 
  posts: /:filename

That will eliminate the post/ from your URL. For .toml you have to slightly alter the formatting.

The homepage solution

If you change line 8 in your layouts/index file from:

{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}

into:

{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}

... you will get the expected result (a list of your posts on the homepage). I tested it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ken M. Haggerty
Solution 2