Use a variable that represents your product name when documenting a project or startup product that might undergo re-branding.
How it works #
The {{<prod>}} shortcode prints out a string for your main product name defined in your site configuration. If the parameter is not configured, it displays a warning message and shows a placeholder text.
Open your repository.
Navigate to the
themes/milo/hugo.yamlfile.Update the following:
yaml# Theme Feature Settings params: names: product: 'Milo Docs'
Header Constraints for TOCs
To ensure Hugo resolves this template in the Table of Contents of your articles, make sure that you use the % wrapper instead of < > in your headers.
Example Error Output: HAHAHUGOSHORTCOD...
Build Configuration
If the
names.product parameter is not configured in your site configuration, the template will display [Product Name Not Configured] and log a warning during the build process. This prevents build failures while alerting you to the missing configuration.Examples #
This is the Example Product theme.
s
This is the {{<prod>}} theme.Source code #
html
{{- $productName := "" -}}
{{- if .Site.Params.names -}}
{{- $productName = .Site.Params.names.product | default "" -}}
{{- end -}}
{{- if $productName -}}
{{- $productName -}}
{{- else -}}
{{- warnf "Product name not found in site configuration. Add 'params.names.product' to your hugo.yaml config. Page: %s" .Page.RelPermalink -}}
[Product Name Not Configured]
{{- end -}}