Skip to content

Commit 14b1298

Browse files
committed
Elevate embedded shortcode documentation to its own section
Closes gohugoio#2805
1 parent 751097f commit 14b1298

File tree

16 files changed

+513
-11
lines changed

16 files changed

+513
-11
lines changed

config/_default/menus/menus.en.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,26 @@ identifier = 'render-hooks'
5555
pageRef = '/render-hooks/'
5656

5757
[[docs]]
58-
name = 'Hugo Modules'
58+
name = 'Shortcodes'
5959
weight = 100
60+
identifier = 'shortcodes'
61+
pageRef = '/shortcodes/'
62+
63+
[[docs]]
64+
name = 'Hugo Modules'
65+
weight = 110
6066
identifier = 'modules'
6167
pageRef = '/hugo-modules/'
6268

6369
[[docs]]
6470
name = 'Hugo Pipes'
65-
weight = 110
71+
weight = 120
6672
identifier = 'hugo-pipes'
6773
pageRef = '/hugo-pipes/'
6874

6975
[[docs]]
7076
name = 'CLI'
71-
weight = 120
77+
weight = 130
7278
post = 'break'
7379
identifier = 'commands'
7480
pageRef = '/commands/'
@@ -77,25 +83,25 @@ pageRef = '/commands/'
7783

7884
[[docs]]
7985
name = 'Troubleshooting'
80-
weight = 130
86+
weight = 140
8187
identifier = 'troubleshooting'
8288
pageRef = '/troubleshooting/'
8389

8490
[[docs]]
8591
name = 'Developer tools'
86-
weight = 140
92+
weight = 150
8793
identifier = 'developer-tools'
8894
pageRef = '/tools/'
8995

9096
[[docs]]
9197
name = 'Hosting and deployment'
92-
weight = 150
98+
weight = 160
9399
identifier = 'hosting-and-deployment'
94100
pageRef = '/hosting-and-deployment/'
95101

96102
[[docs]]
97103
name = 'Contribute'
98-
weight = 160
104+
weight = 170
99105
post = 'break'
100106
identifier = 'contribute'
101107
pageRef = '/contribute/'

content/en/shortcodes/_index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Shortcodes
3+
linkTitle: In this section
4+
description: Insert elements such as videos, images, and social media embeds into your content using Hugo's embedded shortcodes.
5+
categories: []
6+
keywords: []
7+
menu:
8+
docs:
9+
identifier: shortcodes-in-this-section
10+
parent: shortcodes
11+
weight: 10
12+
weight: 10
13+
showSectionMenu: true
14+
---
15+
16+
Insert elements such as videos, images, and social media embeds into your content using Hugo's embedded shortcodes.

content/en/shortcodes/comment.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Comment
3+
description: Include hidden comments in your content with the comment shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
identifier: shortcodes-comment
9+
parent: shortcodes
10+
weight:
11+
weight:
12+
---
13+
14+
{{< new-in "0.137.1" >}}
15+
16+
{{% note %}}
17+
To override Hugo's embedded `comment` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory.
18+
19+
[source code]: {{% eturl comment %}}
20+
{{% /note %}}
21+
22+
Use the `comment` shortcode to include comments in your content. Hugo will ignore the text within these comments when rendering your site.
23+
24+
Use it inline:
25+
26+
```text
27+
{{%/* comment */%}} TODO: rewrite the paragraph below. {{%/* /comment */%}}
28+
```
29+
30+
Or as a block comment:
31+
32+
```text
33+
{{%/* comment */%}}
34+
TODO: rewrite the paragraph below.
35+
{{%/* /comment */%}}
36+
```
37+
38+
Although you can call this shortcode using the `{{</* */>}}` notation, computationally it is more efficient to call it using the `{{%/* */%}}` notation as shown above.

content/en/shortcodes/details.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Details
3+
description: Insert an HTML details element into your content using the details shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
parent: shortcodes
9+
weight:
10+
weight:
11+
toc: true
12+
---
13+
14+
{{< new-in 0.140.0 >}}
15+
16+
{{% note %}}
17+
To override Hugo's embedded `details` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory.
18+
19+
[source code]: {{% eturl details %}}
20+
{{% /note %}}
21+
22+
## Example
23+
24+
With this markup:
25+
26+
```text
27+
{{</* details summary="See the details" */>}}
28+
This is a **bold** word.
29+
{{</* /details */>}}
30+
```
31+
32+
Hugo renders this HTML:
33+
34+
```html
35+
<details>
36+
<summary>See the details</summary>
37+
<p>This is a <strong>bold</strong> word.</p>
38+
</details>
39+
```
40+
41+
Which looks like this in your browser:
42+
43+
{{< details summary="See the details" >}}
44+
This is a **bold** word.
45+
{{< /details >}}
46+
47+
## Arguments
48+
49+
summary
50+
: (`string`) The content of the child `summary` element rendered from Markdown to HTML. Default is `Details`.
51+
52+
open
53+
: (`bool`) Whether to initially display the content of the `details` element. Default is `false`.
54+
55+
class
56+
: (`string`) The `class` attribute of the `details` element.
57+
58+
name
59+
: (`string`) The `name` attribute of the `details` element.
60+
61+
title
62+
: (`string`) The `title` attribute of the `details` element.
63+
64+
## Styling
65+
66+
Use CSS to style the `details` element, the `summary` element, and the content itself.
67+
68+
```css
69+
/* target the details element */
70+
details { }
71+
72+
/* target the summary element */
73+
details > summary { }
74+
75+
/* target the children of the summary element */
76+
details > summary > * { }
77+
78+
/* target the content */
79+
details > :not(summary) { }
80+
```

content/en/shortcodes/figure.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
title: Figure
3+
description: Insert an HTML figure element into your content using the figure shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
parent: shortcodes
9+
weight:
10+
weight:
11+
toc: true
12+
---
13+
14+
{{% note %}}
15+
To override Hugo's embedded `figure` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory.
16+
17+
[source code]: {{% eturl figure %}}
18+
{{% /note %}}
19+
20+
## Example
21+
22+
With this markup:
23+
24+
```text
25+
{{</* figure
26+
src="/images/examples/zion-national-park.jpg"
27+
alt="A photograph of Zion National Park"
28+
link="https://www.nps.gov/zion/index.htm"
29+
caption="Zion National Park"
30+
class="ma0 w-75"
31+
*/>}}
32+
```
33+
34+
Hugo renders this HTML:
35+
36+
```html
37+
<figure class="ma0 w-75">
38+
<a href="https://www.nps.gov/zion/index.htm">
39+
<img
40+
src="/images/examples/zion-national-park.jpg"
41+
alt="A photograph of Zion National Park"
42+
>
43+
</a>
44+
<figcaption>
45+
<p>Zion National Park</p>
46+
</figcaption>
47+
</figure>
48+
```
49+
50+
Which looks like this in your browser:
51+
52+
{{< figure
53+
src="/images/examples/zion-national-park.jpg"
54+
alt="A photograph of Zion National Park"
55+
link="https://www.nps.gov/zion/index.htm"
56+
caption="Zion National Park"
57+
class="ma0 w-75"
58+
>}}
59+
60+
## Arguments
61+
62+
{{< comment >}}
63+
TODO The last thing to do is reword all of these.
64+
{{< /comment >}}
65+
66+
src
67+
: (`string`) URL of the image to be displayed.
68+
69+
class
70+
: (`string`) The `class` attribute of the `figure` element.
71+
72+
alt
73+
: (`string`) Alternate text for the image if the image cannot be displayed.
74+
75+
loading
76+
: (`string`) The `loading` attribute of the `img` element.
77+
78+
height
79+
: (`int`) The `height` attribute of the `img` element.
80+
81+
width
82+
: (`int`) The `width` attribute of the `img` element.
83+
84+
title
85+
: (`string`) Image title.
86+
87+
caption
88+
: (`string`) Image caption. Markdown within the value of `caption` will be rendered.
89+
90+
link
91+
: (`string`) If the image needs to be hyperlinked, URL of the destination.
92+
93+
target
94+
: (`string`) Applicable if the `link` argument is set, the `target` attribule of the anchor element.
95+
96+
rel
97+
: (`string`) Optional `rel` attribute for the URL if `link` argument is set.
98+
99+
attr
100+
: (`string`) Image attribution text. Markdown within the value of `attr` will be rendered.
101+
102+
attrlink
103+
: (`string`) If the attribution text needs to be hyperlinked, URL of the destination.
104+
105+
## Image location
106+
107+
The `figure` shortcode resolves internal Markdown destinations by looking for a matching [page resource], falling back to a matching [global resource]. Remote destinations are passed through, and the render hook will not throw an error or warning if unable to resolve a destination.
108+
109+
[page resource]: /getting-started/glossary/#page-resource
110+
[global resource]: /getting-started/glossary/#global-resource
111+
112+
You must place global resources in the assets directory. If you have placed your resources in the static directory, and you are unable or unwilling to move them, you must mount the static directory to the assets directory by including both of these entries in your site configuration:
113+
114+
{{< code-toggle file=hugo >}}
115+
[[module.mounts]]
116+
source = 'assets'
117+
target = 'assets'
118+
119+
[[module.mounts]]
120+
source = 'static'
121+
target = 'assets'
122+
{{< /code-toggle >}}

content/en/shortcodes/gist.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Gist
3+
description: Embed a GitHub Gist in your content using the gist shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
parent: shortcodes
9+
weight:
10+
weight:
11+
---
12+
13+
TODO

content/en/shortcodes/highlight.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Highlight
3+
description: Insert syntax-highlighted code into your content using the highlight shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
parent: shortcodes
9+
weight:
10+
weight:
11+
---
12+
13+
TODO
14+
15+
{{% note %}}
16+
With the Markdown [content format], the `highlight` shortcode is rarely needed because, by default, Hugo automatically applies syntax highlighting to fenced code blocks.
17+
18+
The primary use case for the `highlight` shortcode in Markdown is to apply syntax highlighting to inline code snippets.
19+
20+
[content format]: /content-management/formats/
21+
{{% /note %}}

content/en/shortcodes/instagram.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Instagram
3+
description: Embed an Instagram post in your content using the instagram shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
parent: shortcodes
9+
weight:
10+
weight:
11+
---
12+
13+
TODO

content/en/shortcodes/param.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Param
3+
description: Insert a front matter field into your content using the param shortcode.
4+
categories: [shortcodes]
5+
keywords: []
6+
menu:
7+
docs:
8+
parent: shortcodes
9+
weight:
10+
weight:
11+
---
12+
13+
TODO

0 commit comments

Comments
 (0)