All of those sections had flat urls, like .../industry-aa, .../industry-ab, etc. With a url and aliases in frontmatter of the _index.de.md I was even able to create translated urls, like .../de/branche-aa instead of ../de/industry-a.
Those pages have been configured in config.toml as a part of navigation, like
Now I’ve added a new page, Industries (just like any other of those pages), having the URL like .../industriesor .../de/branchen, added it to the main navigation and now I need to make those industryA[X] pages to act like children of the new Industries page, while keeping their flat URLs intact. “Children” meaning that when navigating to those flat URLs, defined within every industry page, the main navigation should highlight the parent (“Industries”). I’d also would be glad to organize the content differently, so all those single industry folders are within the “industries” folder of the parent section.
Just in case you feel limited by the search dropdown I get better results with “gohugo search term or string” on Google. I think the search shows not enough results sometimes or links to the same result. With gohugo as search term you will mostly always hit the docs in the first results.
about your question:
What you describe sounds to me more like a taxonomy. Fruits: apples, pears… something like this? You could define industry: industries under the taxonomies section of the config and then you can have a structure like content/industries/industryAA and use filters and links for taxonomies.
Which basically sounds like your new setup, so I am not sure if there is any issue. What’s the question?
if it’s just about highlighting the main navigation item if a subitem is loaded, then have a look at this:
.Parent might be the one you are looking for: “if the current pages parent is taxonomies then mark this menu item active”.
davidsneighbour
This is what I use (see code sample above). The problem I have is that instead of the page defined in content/industries/industryAA with the URL /industryAA it shows the page defined in content/industries which has its own (different) url parameter – /industries.
So basically, I’ve moved all the old content within content/industries folder, haven’t changed a thing – and it is broken, as it shows the same page for every URL defined within those folders. And of course the navigation is not highlighting the main navigation item (why would it):
{{ $currentPage := . }}
{{- range .Site.Menus.main -}}
<li {{ if $currentPage.IsMenuCurrent "main" . }}class="selected"{{ end }}><a href="{{ .URL | absLangURL }}">{{ .Name | markdownify }}</a></li>
{{ end -}}
Perhaps I’m not seeing enough of the site structure to understand this completely, but if a directory represents a single page, its “index” file should be named index.md instead of _index.md. That would allow you set the URLs in site configuration with permalinks instead of setting the url parameter in the front matter of each page.
Additionally, if you are defining the menu in your site configuration, use pageRef instead of url for the menu entries that point to internal pages. This will allow you to leverage the .IsMenuCurrent and .HasMenuCurrent methods.