« RawContent and Content Fingerprints in Hugo
Specifying URL Path Segments in Hugo »

Variable and Parameter Names in Hugo (featuring camelCase⁠🐫 and snake_case⁠🐍)
Updated  2022-April-21

Page contents


2022-August-25  As of today, this evolving⁠[1] article has been on the web for 1 year.🎂


In this article, the words parameter and variable are synonyms.

A variable name that a Hugo user creates is called a custom variable or a user-⁠defined variable.


Allowed characters in Hugo variable names

The names of Hugo variables (including those specified in config files and front matter)…

  • can contain underscores (_) and alphanumeric characters,

  • must start with an underscore (_) or alpha character,

  • and must not contain a dash character (-).[2]

User-defined variables in a layout file must start with a dollar sign ($).


Case sensitivity of Hugo variable names


Built-in variables

In a Hugo config file, built-in variables — such as baseURL, enableEmoji, enableInlineShortcodes, languageCode, Permalinks, themes, themesDir, and title — are sometimes case sensitive so I recommend that you specify them using the upper- and lower-case letters that are specified in gohugo.io/getting-started/configuration/.


The casing used in the variable names enableEmoji, enableInlineShortcodes, languageCode, and themesDir is called camelCase⁠🐫.⁠[3]


Page-level variables

“Page-level .Params⁠[4] are only accessible in lowercase.”


Custom variables

Because of the above and other case-sensitivity issues, Bep, Hugo’s lead developer, recommends all lower case snake_case🐍 for custom variable names. For more about this, see discourse.gohugo.io’s Best practices for naming variables etc.


Hugo variable references

See also


1. Many Infinite Ink articles, including this one, are evergreen and regularly updated.
2. The Unicode name for the “dash” character (-) is “hyphen-minus,” but its proper name is rarely used. Instead, it is usually called “dash,” “hyphen,” or “minus.” Details are at wikipedia.org’s Hyphen-minus.
3. Sometimes this type of casing is called “lower camelCase.”
4. Page-level .Params are usually specified in front matter.

Comments and questions 📝 🤔 👎 👍

Your public comment or question might immediately improve this page or help me to (eventually) improve this page.