hugo-theme-relearn/exampleSite/content/shortcodes/siteparam.en.md

76 lines
1.5 KiB
Markdown
Raw Normal View History

+++
2024-10-12 17:28:28 +00:00
categories = ["howto", "reference"]
description = "Get value of site params"
title = "SiteParam"
+++
The `siteparam` shortcode prints values of params contained in your `hugo.toml`.
## Usage
{{< tabs groupid="shortcode-parameter">}}
{{% tab title="shortcode" %}}
````go
{{%/* siteparam name="editURL" */%}}
````
{{% /tab %}}
{{% tab title="shortcode (positional)" %}}
````go
{{%/* siteparam "editURL" */%}}
````
{{% /tab %}}
{{% tab title="partial" %}}
````go
{{ partial "shortcodes/siteparam.html" (dict
"page" .
"name" "editURL"
)}}
````
{{% /tab %}}
{{< /tabs >}}
### Parameter
| Name | Position | Default | Notes |
|----------------------|----------|------------------|-------------|
| **name** | 1 | _&lt;empty&gt;_ | The name of the site param to be displayed. |
## Examples
### `editURL`
```go
`editURL` value: {{%/* siteparam name="editURL" */%}}
```
`editURL` value: {{% siteparam name="editURL" %}}
### Nested Parameter with Markdown and HTML Formatting
To use formatted parameter, add this in your `hugo.toml`:
2024-03-02 10:04:52 +00:00
{{< multiconfig file=hugo >}}
[markup.goldmark.renderer]
2024-03-02 13:19:46 +00:00
unsafe = true
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
Now values containing Markdown will be formatted correctly.
2024-03-02 10:04:52 +00:00
{{< multiconfig file=hugo >}}
[params]
2024-03-02 13:19:46 +00:00
[params.siteparam.test]
text = 'A **nested** parameter <b>with</b> formatting'
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
```go
Formatted parameter: {{%/* siteparam name="siteparam.test.text" */%}}
```
Formatted parameter: {{% siteparam name="siteparam.test.text" %}}