Isolate page specific url portion of full url

Hello All,
Please, if you can review the below, I do believe there is a way to do this, but I seem to be at an impasse:

Taking a URL such as:

I would like to from each .Page get that pages specific portion of the above url.
(would object be the correct word? .Page object?)


|-about-us-| ← folder
    |-_index.html <— what renders as “about-us”
    |-lookie-here-ma.html <— what renders as “lookie-here-ma”

How can I have .Page in all cases return the value of that pages specific portion of the URL?


.Slug for About-us (_index.html) works just fine and renders as (/about-us/)
But, .Slug for lookie-here-ma.html renders to (/about-us/lookie-here-ma/) <— I just want “lookie-here-ma”

.File.BaseFileName for about-us (_index.html) renders as (_index.html) <— Bad - I want “about-us”
But, for lookie-here-ma.html works just fine and renders as (/lookie-here-ma/)

I could do a test i.e. “If you are not a .Section then do one, if you aren’t do another”, but it seems that their is just a standard Hugo way to do this, that I’m just not seeing… Or some intense symdiff work, but still, I’m sure there is something I’m just missing.

If anyone could guide me, I’d much appreciate.

Thank you All.

{{ .RelPermalink | path.Base }}

Che, seriously now, I looked at that page (path.Base) I don’t know how many times and keep thinking, “ahh… no, that’s not it”

I misunderstood path in that context.

Thank you very much, this absolutely gives me what I need and works perfectly.

Thought, honestly in this case, you’ve genuinely helped me 4x is it now?

This begs the question, do we have some system when professional help is given on this discourse to remunerate that assistance? Even if it’s just a coffee or something?

Pay it forward. :smiley:


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