2019-10-21 04:22:28 -04:00
---
title: .Param
2023-01-17 06:51:01 -05:00
description: Returns a page parameter, falling back to a site parameter if present.
signature: ['.Param KEY']
2019-10-21 04:22:28 -04:00
categories: [functions]
2023-01-17 06:51:01 -05:00
keywords: ['front matter', 'params']
2019-10-21 04:22:28 -04:00
menu:
docs:
2023-01-17 06:51:01 -05:00
parent: 'functions'
2019-10-21 04:22:28 -04:00
aliases: []
---
2023-01-17 06:51:01 -05:00
The `.Param` method on `.Page` looks for the given `KEY` in page parameters, and returns the corresponding value. If it cannot find the `KEY` in page parameters, it looks for the `KEY` in site parameters. If it cannot find the `KEY` in either location, the `.Param` method returns `nil` .
2019-10-21 04:22:28 -04:00
2023-01-17 06:51:01 -05:00
Site and theme developers commonly set parameters at the site level, allowing content authors to override those parameters at the page level.
2019-10-21 04:22:28 -04:00
2023-01-17 06:51:01 -05:00
For example, to show a table of contents on every page, but allow authors to hide the table of contents as needed:
2019-10-21 04:22:28 -04:00
2023-01-17 06:51:01 -05:00
**Configuration**
2019-10-21 04:22:28 -04:00
2023-01-17 06:51:01 -05:00
{{< code-toggle file = "config" copy = false > }}
[params]
display_toc = true
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-01-17 06:51:01 -05:00
**Content**
2019-10-21 04:22:28 -04:00
2023-01-17 06:51:01 -05:00
{{< code-toggle file = "content/about.md" fm = true copy = false > }}
title = 'About'
date = 2023-01-01
draft = false
display_toc = false
{{< / code-toggle > }}
**Template**
{{< code file = "layouts/_default/single.html" copy = "false" > }}
{{ if .Param "display_toc" }}
{{ .TableOfContents }}
{{ end }}
{{< / code > }}
The `.Param` method returns the value associated with the given `KEY` , regardless of whether the value is truthy or falsy. If you need to ignore falsy values, use this construct instead:
{{< code file = "layouts/_default/single.html" copy = "false" > }}
{{ or .Params.foo site.Params.foo }}
{{< / code > }}