aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-07-21 11:34:26 +0200
committerBjørn Erik Pedersen <[email protected]>2021-07-21 11:36:15 +0200
commit32508045d36a0ca70d10216afc78e1804aa2186d (patch)
treee9deeb97f81e5a66f18d4f84ca069a8ec20381ae
parente521c9a36d89dfc2f4117af4bca5c2a0731eed61 (diff)
downloadhugo-32508045d36a0ca70d10216afc78e1804aa2186d.tar.gz
hugo-32508045d36a0ca70d10216afc78e1804aa2186d.zip
navigation: Check Page first in URL()
In Hugo #8776 we added `pageRef`, a way to connect menu items in site config to pages. This means that you now can have both a Page and a configured URL. Having the configured URL as a fallback if the Page isn't found is obviously more useful, especially in multilingual sites. See #8776
-rw-r--r--navigation/menu.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/navigation/menu.go b/navigation/menu.go
index 7c6a1ccc7..dd62f825e 100644
--- a/navigation/menu.go
+++ b/navigation/menu.go
@@ -46,15 +46,19 @@ type MenuEntry struct {
}
func (m *MenuEntry) URL() string {
- if m.ConfiguredURL != "" {
- return m.ConfiguredURL
- }
+ // Check page first.
+ // In Hugo 0.86.0 we added `pageRef`,
+ // a way to connect menu items in site config to pages.
+ // This means that you now can have both a Page
+ // and a configured URL.
+ // Having the configured URL as a fallback if the Page isn't found
+ // is obviously more useful, especially in multilingual sites.
if !types.IsNil(m.Page) {
return m.Page.RelPermalink()
}
- return ""
+ return m.ConfiguredURL
}
// A narrow version of page.Page.