diff --git a/hugo.toml b/hugo.toml index be41e7cd..8bdd1bc6 100644 --- a/hugo.toml +++ b/hugo.toml @@ -99,7 +99,8 @@ weight = 1 [menus.main.params] # Add CSS class to a specific menu item. class = "" -# Whether set as a draft menu item whose function is similar to a draft post/page. +# Whether set as a draft menu item, hidden by default. +# Visible when env var is set: HUGO_PARAMS_MENU_DRAFT=true hugo server draft = false # Add FontAwesome icon to a specific menu item. icon = "fa-solid fa-archive" diff --git a/layouts/_partials/base/header.html b/layouts/_partials/base/header.html index abb1f44b..f02f564c 100644 --- a/layouts/_partials/base/header.html +++ b/layouts/_partials/base/header.html @@ -10,7 +10,13 @@ Called from: layouts/baseof.html. */ -}} -{{- $buildDrafts := .Page.Draft -}} +{{- /* + Whether to show draft menu items in the navigation. + Controlled via env var at build time: HUGO_PARAMS_MENU_DRAFT=true hugo server + Replaces the deprecated .Site.BuildDrafts (Hugo v0.156.0). + See: https://discourse.gohugo.io/t/deprecations-in-v0-156-0/56732/11 +*/ -}} +{{- $menuDraft := getenv "HUGO_PARAMS_MENU_DRAFT" -}} {{- $relLangURL := relLangURL "" -}} {{- /* Desktop header */ -}} @@ -57,51 +63,53 @@ {{- with .Page -}} {{- $url = .RelPermalink -}} {{- end -}} - {{- if (ne .Params.Draft true) | or $buildDrafts | and (ne .Params.Type "mobile") -}} -