My navigation and URL references go nuts – and I can’t see the pattern which might need fixing.
Here is the navigation template:
<div class="d-none d-md-flex mr-2">
<ul class="nav-main">
{{ $currentPage := . }}
{{- range .Site.Menus.main -}}
<li class="{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}selected{{ end }} {{ if .HasChildren }}dropdown{{end}}">
<a {{- if gt (len .Pre) 0 }}class="{{.Pre}}"{{ end }} href="{{ .URL | absLangURL }}">{{ .Name | markdownify }}</a>
{{ if .HasChildren }}
<ul class="sub">
{{ range .Children }}
<li class="{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}selected{{ end }}">
<a href="{{ .URL | absLangURL }}">
{{ $icon := (.Pre) }}
{{ if $icon }}
<i class="nav-deco nav-deco--{{ .PageRef }} ico {{$icon}}"></i>
{{ end }}
<div>
<span class="title">{{ .Name | markdownify }}</span>
<span class="description">{{ .Post }}</span>
</div>
</a></li>
{{ end }}
{{ if eq .PageRef "industries" }}
<li>
<a href="{{.URL | absLangURL }}">
<div>
<span class="title">{{ i18n "moreIndustriesNavi"}}</span>
</div>
</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end -}}
</ul>
</div>
Here is the entry in the config.toml for the pages in question:
# ENGLISH
[languages]
[languages.en]
weight = 1
title = "Shift scheduling and team management – smart, easy, free"
languageName = "English"
[languages.en.params]
langcode = "English"
lang = "en"
[[languages.en.menu.main]]
name = "Product"
weight = 1
url = "/product"
pageref = "product"
[[languages.en.menu.main]]
name = "Scheduling"
weight = 10
url = "/shift-planner/"
pageref = "shift-planner"
parent = "Product"
pre = "i-calendar"
post = "Some description"
[[languages.en.menu.main]]
name = "Management"
weight = 12
url = "/manager-app/"
pageref = "manager-app"
parent = "Product"
pre = "i-team"
post = "Some description"
[[languages.en.menu.main]]
name = "Time tracking"
weight = 13
url = "/time-tracking-attendance/"
pageref = "time-tracking"
parent = "Product"
pre = "i-punch-in"
post = "Some description"
[[languages.en.menu.main]]
name = "Payroll"
weight = 14
url = "/payroll/"
pageref = "payroll"
parent = "Product"
pre = "i-wallet"
post = "Some description"
[[languages.en.menu.main]]
name = "Industries"
weight = 2
url = "/industries/"
pageref = "industries"
[[languages.en.menu.main]]
name = "Retail & Shops"
weight = 22
url = "/staff-scheduling-retail/"
pageref = "industry-retail"
post = "Some description"
parent = "Industries"
[[languages.en.menu.main]]
name = "Healthcare & Medical"
weight = 23
url = "/staff-scheduling-pharmacy/"
pageref = "industry-pharmacy"
post = "Some description"
parent = "Industries"
[[languages.en.menu.main]]
name = "Catering & Gastro"
weight = 24
url = "/staff-scheduling-catering/"
pageref = "industry-gastro"
post = "Some description"
parent = "Industries"
[[languages.en.menu.main]]
name = "Hotels & Hospitality"
weight = 25
url = "/staff-scheduling-hotels/"
pageref = "industry-hotels"
post = "Some description"
parent = "Industries"
[[languages.en.menu.main]]
name = "Security & Surveillance"
weight = 26
url = "/industry-security/"
pageref = "industry-security-guards"
post = "Some description"
parent = "Industries"
[[languages.en.menu.main]]
name = "Pricing"
weight = 8
url = "/pricing/"
pageref = "pricing"
[[languages.en.menu.main]]
name = "Resources"
weight = 7
url = "/resources/"
pageref = "resources"
[[languages.en.menu.main]]
name = "Case studies"
weight = 52
url = "/case-studies/"
pageref = "case-studies"
pre = "i-star ico--color"
post = "qwert"
parent = "Resources"
[[languages.en.menu.main]]
name = "Blog"
weight = 53
url = "/blog/"
pageref = "blog"
pre = "i-speech ico--color"
post = "qwert"
parent = "Resources"
[[languages.en.menu.main]]
name = "Excel templates"
weight = 54
url = "/resources/excel-templates/"
pageref = "excel"
pre = "i-template ico--color"
post = "qwert"
parent = "Resources"
[[languages.en.menu.main]]
name = "Business days"
weight = 55
url = "/resources/business-days/"
pageref = "biz-days"
pre = "i-holiday ico--color"
post = "qwert"
parent = "Resources"
here is the _index.en.md for the Industry page:
---
title: "Page Title"
keywords: "page keywords"
description: "page seo descriptions"
date: 2017-11-21T21:28:43+01:00
draft: false
layout: single
---
I run the local server with $ hugo serve -w --disableFastRender --ignoreCache
When I point my browser to /indusrties
URL it most of the time(!) shows me the resources page instead (as content AND selected in the navigation).
But when I go to sub pages under Industry navigation, it shows them alright, correctly highlighting “Industry” in the navigation.
So I decided to debug what I can. In the navigation template I inserted {{ jsonify $currentPage }}
and this is what I’ve got for the http://localhost:1313/industries
url in the browser:
{
"Date": "2022-03-30T14:28:52+01:00",
"Lastmod": "2022-03-30T14:28:52+01:00",
"PublishDate": "2022-03-30T14:28:52+01:00",
"ExpiryDate": "0001-01-01T00:00:00Z",
"Aliases": null,
"BundleType": "",
"Description": "",
"Draft": false,
"IsHome": false,
"Keywords": null,
"Kind": "page",
"Layout": "",
"LinkTitle": "Industries",
"IsNode": false,
"IsPage": true,
"Path": "/resources/list/industries", <-- WTF?
"Slug": "",
"Lang": "en",
"IsSection": false,
"Section": "resources",
"Sitemap": {
"ChangeFreq": "",
"Priority": -1,
"Filename": "sitemap.xml",
"Disable": false
},
"Type": "resources",
"Weight": 2
}
Interestingly enough, sometimes(!!) I am lucky and get the content what I want to see (most of the time after changing something within that page content or templates) – but then it is not selected in the navigation anyway.
And ideas?