Custom template for one category?

Option 1

blog = /:year/:month/:title/"

With permalinks for blog configured like you have above, you can do the following:

/content/blog/blog-post-name.md

If your content file has date in the frontmatter, Hugo will know to render at yoursite.com/2020/04/blog-post-name/.


Option 2

If you organise your content like:

/content/blog/2020/04/blog-post-name.md

Then you don’t need the permalinks config for blog; Hugo will render your page at yoursite.com/blog/2020/04/blog-post-name.


There are pros and cons to each.

With the first option, you can just dump everything under content/blog/ and Hugo renders the pages at the appropriate year and month subdir: yoursite.com/year/month/title/. However yoursite.com/year/ (and /month/) will not have a list page, ie there will not be a yoursite.com/2020/ with all the 2020-dated posts listed. There are ways around this, but it does not happen ‘automatically’ like the /blog/ section list page would.

With the second option, you have to maintain the year/month organisation in your content yourself, ie you have to create a content/blog/year/month folder yourself for each month for which you have posts. The upside to this is that Hugo is able to generate list pages for you in a pretty straightforward way. (just make sure there is a _index.md file for the sub-folders (ie the year and month sub-folders).


How you organise things is up to you and your preferences.


As for which layout files you need:

  • layouts/blog/list.html
  • layouts/blog/single.html

should do the trick.

I have some more complicated examples in this post I wrote. But I don’t know if that is just information overload at this point :sweat_smile: