How do I remove the top-level section from permalinks?

Here’s the situation:

I have three top-level sections — article, book, and video — like this:

  • content/
    • article/
    • book/
    • video/

…and in the “book” section, I have sub-directories, like this:

  • book/
    • html-tutorial/
    • photoshop-tutorial/

Then each sub-directory has Markdown files, like this:

As a result, I end up with permalinks that look like this:

http://localhost:1313/book/html-tutorial/introduction

But is there an elegant way to remove the “book” part from this permalink?

At the moment, I’ve got the following code in my config.yml file:

permalinks:
  book: /:slug

…and have the “slug” parameter set like this in the front-matter:

slug: "html-tutorial/introduction"

This provides the desired result, but it seems redundant to explicitly include the sub-directory name in the slug, so I was wondering if there was a better way to achieve the same result.

Thanks for any help.

:slight_smile:

1 Like

You could use the url: parameter instead the slug:

1 Like

A post was split to a new topic: How to remove section from permalinks