Files
hugo/docs/content/en/functions/collections/IsSet.md
T
Bjørn Erik Pedersen 30a20122b7 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82'
# Conflicts:
#	docs/data/docs.yaml
2026-02-14 12:14:33 +01:00

1.1 KiB

title, description, categories, keywords, params, aliases
title description categories keywords params aliases
collections.IsSet Reports whether a specific key or index exists in the given map or slice.
functions_and_methods
aliases returnType signatures
isset
bool
collections.IsSet MAP|SLICE KEY|INDEX
/functions/isset

For example, consider this site configuration:

{{< code-toggle file=hugo >}} [params] showHeroImage = false {{< /code-toggle >}}

If the value of showHeroImage is true, we can detect that it exists using either if or with:

{{ if site.Params.showHeroImage }}
  {{ site.Params.showHeroImage }} → true
{{ end }}

{{ with site.Params.showHeroImage }}
  {{ . }} → true
{{ end }}

But if the value of showHeroImage is false, we can't use either if or with to detect its existence. In this case, you must use the isset function:

{{ if isset site.Params "showheroimage" }}
  <p>The showHeroImage parameter is set to {{ site.Params.showHeroImage }}.<p>
{{ end }}

Note

When using the isset function you must reference the key using lower case. See the previous example.