Hide Section name from the Permalink of a Page?

Quite old topic but the problem persists:
What if I’d like to transform content/post/<my-memories>/<memory-1> available at
mysite.com/post/<my-memories> to mysite.com/<my-memories>?

I tried into config.toml

“my-memories” = “/categories/my-memories”
“my-memories” = “/post/my-memories”

post = “/:slug”
category = “/:slug”
“post/my-memories” = “/:slug”

without any success…

post = "/:section/:slug" gives me back /post/<memory-1>

Any help please?

Your question seems to be unrelated to Taxonomies since you are asking about making a page residing under: content/post/<my-memories>/<memory-1> to have a permalink without the section name /post/.

I have moved it to its own topic, since the other one had not seen any activity in 4 years. We discourage bumping of old topics.

With that said you can set the url parameter in a page’s front matter to whatever you wish.

I tried that too:


I created a file


with inside:

category: "my-memories"
url: "my-memories"

nothing changed.

No you need to set the url parameter in the actual content page -from your post above it seems that you need to do this in the front matter of memory-1.md and not in it the _index.md of its Nested Section my-memories.

It means I have to create the my-memory-1.md into /content/post/my-memories/memory-1?

Into /content/post/my-memories/ I have several other files such as

| - 2018.md
| - 2019.md

I’m trying it right now, let’s see.

EDIT: created the file but nothing changed:

categories : ["my-memories"]
url: "/my-memories/memory-1/"

Please share the repo or if you cannot provide a sample repo. In the README write exactly which content file you want to have a different URL than its default one.

We need to see the full context of what’s going on in your project.

I’ll write the full tree of folders, I would prefer not to share the repo yet until everything isn’t ready.

| content
| - page
| -- about
| - post
| -- accessori
| --- ravpower
| ---- powerbank.md
| ---- charger.md
| -- fotografia
| --- canon-m6.md

When I from my category list I click on the link of each post I am headed to mydomain.com/post/accessori/ravpower/powerbank/

According to your suggestion I would need to write into

| content
| - post
| -- accessori
| --- ravpower

a file ravpower.md

categories : ["accessori"]
url: "/accessori/ravpower/"

But nothing is working so far

What are the contents of your config? Post it in its entirety without the baseURL and other identifiable parameters.

Also are you sure that the posts in question are published? (i.e. they’re not drafts or dated in the future).

Of course they are published! I can see them in the list of posts. But I can see them even after I create the file ravpower.md…just I don’t see the link changing.

Here is my config.toml:

baseURL = "https://localhost"
languageCode = "it-IT"
title = "title"
theme = "theme"
publishDir = ""

# Enable comments by entering your Disqus shortname
disqusShortname = ""
# Enable Google Analytics by entering your tracking code
googleAnalytics = ""
preserveTaxonomyNames = true
paginate = 7

    category    =   "categories"
    tag         =   "tags"

    # Non modificare
    categories = "/:slug"
    tags = "/:slug"
    # /Non modificare

#    post = "/:filename"
#    page = "/:slug/"
#    post =   "/:section/:slug"

        # set to true to disable service 
        disable = false
        # set to true to meet General Data Protection Regulation (GDPR)
        anonymizeIP = true
        respectDoNotTrack = false
        useSessionStorage = false

    author = "Nipa"
    image  = "/img/logo_1x1.png"
    slogan = "description"
    copyright = [
        "&copy; 2018-YEAR NI-PA"

# Nav links in the side bar
    name = "Tutti i post"
    url = "/"
    weight = 1

    name = "Accessori"
    identifier = "accessori"
    url = "accessori/"
    weight = 2

    name = "Ravpower"
    parent = "accessori"
    url = "ravpower/"
    weight = 2

    name = "Aukey"
    parent = "accessori"
    url = "aukey"
    weight = 2

Here is a sample repo, that I took the time to make as per your description above: https://github.com/onedrawingperday/testing

If you clone it and test it locally, you will see that when one visits: http://localhost:1313/accessori/ravpower/ the page under /content/post/accessori/ravpower.md is published.

I cannot reproduce your issue.

1 Like

Well, I can just send you a very big thank you for the time you used to help me.

Your example works only when you insert url: "my-url" into each of the .md files
ravpower.md is supposed to be ravpower/ (a folder) in which there are several other files such as charger.md, powerbank.md etc.

Your example works only if I insert url into each of those .md files. Better than nothing though, even if in such a way I have to invent a title for each url of the file to be pointed whereas in normal conditions it’s hugo to do so

If you want to hide the /post/ section from the permalinks of all children pages then you can do the following:

In config.toml configure the Permalinks for the /post/ section like so:

    post = "/accessori/:filename"

With the above you will not have to manually enter a url parameter in the front matter of each page.

The :filename variable refers to the filename of a content file but if you choose to use Page Bundles it will refer to the name of the folder that contains an index.md

But in such a way I cannot access in the correct way to other “categories” (cfr. Fotografia) that is another category for me because all the traffic is directed to accessori:

| content
| - page
| -- about
| - post
| -- accessori
| --- ravpower
| ---- powerbank.md
| ---- charger.md
| -- **fotografia**
| --- canon-m6.md

Because I will point to accessori/canon-m6 whereas I’d like to point to fotografia/canon-m6

Hi @alexandros. at the end I gave up and I changed the tree of my content removing definitively the post/ folder. I was just wondering, anyway, if there would be anyway to shortcut the formation of the parameter url something like

category : ["cat1", "cat2"]
url = {{.category[0]}} "my-custom-id"

Not as you quoted above.

Template variables and functions are not available in the Front Matter of content files but only for Archetypes.

However since you removed the parent /post/ folder and the product sections now live directly under the contentDir you can configure each section’s permalinks in the config, without needing to use the url parameter.

For example

    accessori = "/:section/:filename"
    fotografia= "/:section/:slug"

Unless of course you are trying to do something different.


Thank you for your time and your patient, really :slight_smile:

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