3

I'm trying to build a structure for permalinks in Hugo + blogdown where a post will have the permalink structure of

websitename/category/slug

Not sure how to do this because I've set the config.toml permalink structure to

    [permalinks] 
        posts = "/:section/:slug"

and I place the post (an .md file) into a folder, which is a category, underneath the posts file but I get a url similar to websitename/posts/category/slug... when what I really want is websitename/category/slug.

I was hoping to make the category the section, but not have "post" in the URL.

I'm still trying to figure out where to place the _index.md file but have not been very successful. Any help would be appreciated.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
zad
  • 83
  • 7
  • 1
    What does this have to do with the R programming language? ([tag:r] tag) – r2evans Jan 21 '19 at 23:49
  • 1
    Could you post your website repo? which theme are you using? – TC Zhang Jan 21 '19 at 23:49
  • Hi. I'm using beautiful hugo, not sure if i Could post the website repo because it's not being served by anything like Github pages or netlify – zad Jan 22 '19 at 02:50
  • 1
    @r2evans it was made using blogdown, so I thought others who had experience with the package could chime in – zad Jan 22 '19 at 02:51

1 Answers1

2

The permalink is set on a per section basis. The sections are the first-level directories under content, not under content/posts/.

So, if you want the permalink to be websitename/category/slug, arrange category directories(or sections by the Hugo term) like this:

content
├── category1
│   └── 2015-01-04-first-post.md
├── category2
│   └── 2015-01-27-dear-diary.md
├── _index.md
├── page
│   └── about.md
└── post
    ├── 2017-03-07-bigimg-sample.md
    └── 2017-03-20-photoswipe-gallery-sample.md

and set

[permalinks] 
    category1 = "/:section/:slug"
    category2 = "/:section/:slug"
    page = "/:section/:slug"
    post = "/:section/:slug"

in your config.yaml

Source: https://gohugo.io/content-management/urls/#permalinks

TC Zhang
  • 2,757
  • 1
  • 13
  • 19