2021-08-25 11:33:29 +00:00
|
|
|
+++
|
2024-10-12 17:28:28 +00:00
|
|
|
categories = ["howto", "reference"]
|
2022-06-05 17:31:59 +00:00
|
|
|
description = "Get value of site params"
|
2023-07-26 20:29:03 +00:00
|
|
|
title = "SiteParam"
|
2021-08-25 11:33:29 +00:00
|
|
|
+++
|
2017-09-04 20:24:36 +00:00
|
|
|
|
2024-10-04 23:49:00 +00:00
|
|
|
The `siteparam` shortcode prints values of params contained in your `hugo.toml`.
|
2021-10-24 09:34:29 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2023-07-27 15:02:13 +00:00
|
|
|
{{< tabs groupid="shortcode-parameter">}}
|
2023-06-05 21:20:37 +00:00
|
|
|
{{% tab title="shortcode" %}}
|
2022-06-05 17:31:59 +00:00
|
|
|
|
2021-10-24 09:34:29 +00:00
|
|
|
````go
|
2022-06-05 17:31:59 +00:00
|
|
|
{{%/* siteparam name="editURL" */%}}
|
2021-10-24 09:34:29 +00:00
|
|
|
````
|
|
|
|
|
2022-06-05 17:31:59 +00:00
|
|
|
{{% /tab %}}
|
2023-06-05 21:20:37 +00:00
|
|
|
{{% tab title="shortcode (positional)" %}}
|
2021-10-24 09:34:29 +00:00
|
|
|
|
2022-06-05 17:31:59 +00:00
|
|
|
````go
|
|
|
|
{{%/* siteparam "editURL" */%}}
|
|
|
|
````
|
2017-09-04 20:24:36 +00:00
|
|
|
|
2022-06-22 22:03:24 +00:00
|
|
|
{{% /tab %}}
|
2023-06-05 21:20:37 +00:00
|
|
|
{{% tab title="partial" %}}
|
2022-06-22 22:03:24 +00:00
|
|
|
|
|
|
|
````go
|
|
|
|
{{ partial "shortcodes/siteparam.html" (dict
|
2023-07-27 14:14:55 +00:00
|
|
|
"page" .
|
2022-06-22 22:03:24 +00:00
|
|
|
"name" "editURL"
|
|
|
|
)}}
|
|
|
|
````
|
|
|
|
|
2022-06-05 17:31:59 +00:00
|
|
|
{{% /tab %}}
|
|
|
|
{{< /tabs >}}
|
2017-09-04 20:24:36 +00:00
|
|
|
|
2022-06-05 17:31:59 +00:00
|
|
|
### Parameter
|
|
|
|
|
|
|
|
| Name | Position | Default | Notes |
|
2023-07-27 14:07:01 +00:00
|
|
|
|----------------------|----------|------------------|-------------|
|
2022-06-05 17:31:59 +00:00
|
|
|
| **name** | 1 | _<empty>_ | The name of the site param to be displayed. |
|
2017-09-04 20:24:36 +00:00
|
|
|
|
2022-06-05 17:31:59 +00:00
|
|
|
## Examples
|
|
|
|
|
2024-10-04 23:49:00 +00:00
|
|
|
### `editURL`
|
2017-09-04 20:24:36 +00:00
|
|
|
|
2021-08-23 21:32:34 +00:00
|
|
|
```go
|
2022-06-05 17:31:59 +00:00
|
|
|
`editURL` value: {{%/* siteparam name="editURL" */%}}
|
2017-09-04 20:24:36 +00:00
|
|
|
```
|
|
|
|
|
2022-06-05 17:31:59 +00:00
|
|
|
`editURL` value: {{% siteparam name="editURL" %}}
|
2023-07-26 20:29:03 +00:00
|
|
|
|
2024-10-04 23:49:00 +00:00
|
|
|
### Nested Parameter with Markdown and HTML Formatting
|
2023-07-26 20:29:03 +00:00
|
|
|
|
2023-11-29 23:14:22 +00:00
|
|
|
To use formatted parameter, add this in your `hugo.toml`:
|
2023-07-26 20:29:03 +00:00
|
|
|
|
2024-03-02 10:04:52 +00:00
|
|
|
{{< multiconfig file=hugo >}}
|
2023-07-26 20:29:03 +00:00
|
|
|
[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.
|
2023-07-26 20:29:03 +00:00
|
|
|
|
2024-03-02 10:04:52 +00:00
|
|
|
{{< multiconfig file=hugo >}}
|
2023-07-26 20:29:03 +00:00
|
|
|
[params]
|
2024-03-02 13:19:46 +00:00
|
|
|
[params.siteparam.test]
|
2024-10-12 16:37:59 +00:00
|
|
|
text = 'A **nested** parameter <b>with</b> formatting'
|
2024-03-02 10:04:52 +00:00
|
|
|
{{< /multiconfig >}}
|
2023-07-26 20:29:03 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
Formatted parameter: {{%/* siteparam name="siteparam.test.text" */%}}
|
|
|
|
```
|
|
|
|
|
|
|
|
Formatted parameter: {{% siteparam name="siteparam.test.text" %}}
|