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