Removing the folder name from the article link

My folder construction is as follows:


This is the content of file:

title: What is a Webmaster?
slug: what-webmaster

Although I set the slug value to what-webmaster, the link to my article is as follows:

The reason why my article is in the webmaster folder is to create a layout of my own, but it adds the folder name /webmaster/ to the link of my article without my request.

How can I remove the /webmaster/ folder from my article link?

If you want to do the same thing for all pages in the webmaster folder, set permalinks in the site configuration.

1 Like

post = "/:slug/"

I tried that but it didn’t work.

webmaster = "/:slug/"

This works fine.

1 Like

If I want to do this to all folders, what should I put in the word webmaster?

webmaster = "/:slug/"
seo = "/:slug/"
books = "/:slug/"
1 Like

The permalinks setting applies to regular pages, not section pages. To set the URL for section pages, you will need to set the url in front matter.

There’s an open issue about this:

1 Like

posts = "/:slug/"

posts = "/:slug/"

This is how it is used in the link you mentioned, but when I start hugo, I get an error like this:

panic: runtime error: slice bounds out of range [1:0]
goroutine 1 [running]:{0xc00030a4b0?, 0x0?, 0xc00013fda0?}, {0x0?, 0x0?})
        /root/project/hugo/resources/page/permalinks.go:183 +0x23b{0xc00030a4b0?, 0x0?, 0xc00013fda0?}, 0x8?)
        /root/project/hugo/resources/page/permalinks.go:126 +0x136
        /root/project/hugo/resources/page/permalinks.go:95 +0x7a5, 0xc00013fe30, {0x28913e0, 0xc00011ea98}, {0x28b0110, 0xc0001a9c20}, {0x2891400?, 0xc00000a9e0}, 0xc000119cc0, {0xc0001b2000, ...}, ...)
        /root/project/hugo/resources/resource_spec.go:76 +0x205{{0x28b0110, 0xc0001a9c20}, 0xc00020e7e0, 0xc0006c8f00, {0x0, 0x0}, {0x28ad5e0, 0xc0004a1090}, {0xc000716000, 0x22, ...}, ...})
        /root/project/hugo/deps/deps.go:289 +0x705{{0x0, 0x0}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}}, ...)
        /root/project/hugo/hugolib/hugo_sites.go:519 +0x31e{{0x28b0110, 0xc0001a9c20}, 0xc00020e7e0, 0x0, {0x0, 0x0}, {0x28ad5e0, 0xc0004a1090}, {0x0, 0x0, ...}, ...}, ...)
        /root/project/hugo/hugolib/hugo_sites.go:406 +0x766{{0x28b0110, 0xc0001a9c20}, 0xc00020e7e0, 0x0, {0x0, 0x0}, {0x28ad5e0, 0xc0004a1090}, {0x0, 0x0, ...}, ...})
        /root/project/hugo/hugolib/hugo_sites.go:555 +0x158*commandeer).loadConfig.func3()
        /root/project/hugo/commands/commandeer.go:498 +0x8d8
sync.(*Once).doSlow(0xc0004a1090?, 0x21926e1?)
        /usr/local/go/src/sync/once.go:74 +0xc2
        /root/project/hugo/commands/commandeer.go:423 +0xa4b, 0x1, 0x1, 0xc0002f9c20, {0x2891380?, 0xc00058e540}, 0xc00058db20, {0x0, 0x0, 0x0})
        /root/project/hugo/commands/commandeer.go:227 +0x31f, 0x0?, 0x0?, 0x2176e62?, {0x2891380?, 0xc00058e540?}, 0x0?)
        /root/project/hugo/commands/hugo.go:125 +0x3b*serverCmd).server(0xc00058e540, 0xc0008b2000, {0x0?, 0x0?, 0x0?})
        /root/project/hugo/commands/server.go:257 +0x1cd*commandsBuilder).newServerCmdSignaled.func1(0xc0008b2000?, {0x37750f8?, 0x0?, 0x0?})
        /root/project/hugo/commands/server.go:96 +0x36*Command).execute(0xc0008b2000, {0x37750f8, 0x0, 0x0})
        /root/project/gomodcache/ +0x862*Command).ExecuteC(0xc0003f8900)
        /root/project/gomodcache/ +0x3bd{0xc0001163b0, 0x1, 0x1})
        /root/project/hugo/commands/hugo.go:92 +0xbd
        /root/project/hugo/main.go:23 +0x56

It is an open issue. As in, it has not been implemented.

1 Like

thank you for the answer

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.