Here is the code to generate the breadcrumbs which should link to the individual sections. Each section should show a list of pages which are inside this section.
As you can see I had to manually include the .html suffix. That means if I remove uglyURLs = true from my config in the future I also have to remove the hardcoded .html ending from my templates. I don’t think this is right.
So here is my question: How do I generate a link to a section from inside a single page?
My goal is to have a help page very similar to https://help.github.com/. Not the first “Common Issues” block but below that one.
Assuming you are asking how to link to a section’s index page (i.e., a list template) from within a single page template, you might find some utility in the .GetPage function.
Would need to be modified per your templating, but just so you can get an idea of how to use the function, which requires a kind for a first argument and a second argument…
I’m not sure why you need the urglyURLs = true but in my case, I just use the url without “.html” prefix which is the “pretty” url, and just link it using "/{{ .Section | urlize }}". This makes life much easier.
I’m not sure if I follow this question, because I don’t see a problem. In Hugo, we only have a top-most section (see this doc page, for example).
Because .Section returns the section of the current page, and because there’s only one possible section for each content (or no section at all), I think this will always generate a link to your section page (it does in my case, at least):
{{ .Site.BaseURL }}/{{ .Section }}/
Or, if you’re using ugly URLs:
{{ .Site.BaseURL }}/{{ .Section }}.html
I don’t see the need to complicate matters with the .GetPage function, since you’re only looking to generate a URL to the current section, right?
Tends to be more fragile…and until recently, usage was pretty inconsistent, especially in themes. {{ "whatever-string" | absURL }} is more consistent. See this comment in a related issue: