-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elevate embedded shortcode documentation to its own section
Closes #2805
- Loading branch information
Showing
16 changed files
with
513 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: Shortcodes | ||
linkTitle: In this section | ||
description: Insert elements such as videos, images, and social media embeds into your content using Hugo's embedded shortcodes. | ||
categories: [] | ||
keywords: [] | ||
menu: | ||
docs: | ||
identifier: shortcodes-in-this-section | ||
parent: shortcodes | ||
weight: 10 | ||
weight: 10 | ||
showSectionMenu: true | ||
--- | ||
|
||
Insert elements such as videos, images, and social media embeds into your content using Hugo's embedded shortcodes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: Comment | ||
description: Include hidden comments in your content with the comment shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
identifier: shortcodes-comment | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
--- | ||
|
||
{{< new-in "0.137.1" >}} | ||
|
||
{{% note %}} | ||
To override Hugo's embedded `comment` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory. | ||
|
||
[source code]: {{% eturl comment %}} | ||
{{% /note %}} | ||
|
||
Use the `comment` shortcode to include comments in your content. Hugo will ignore the text within these comments when rendering your site. | ||
|
||
Use it inline: | ||
|
||
```text | ||
{{%/* comment */%}} TODO: rewrite the paragraph below. {{%/* /comment */%}} | ||
``` | ||
|
||
Or as a block comment: | ||
|
||
```text | ||
{{%/* comment */%}} | ||
TODO: rewrite the paragraph below. | ||
{{%/* /comment */%}} | ||
``` | ||
|
||
Although you can call this shortcode using the `{{</* */>}}` notation, computationally it is more efficient to call it using the `{{%/* */%}}` notation as shown above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
title: Details | ||
description: Insert an HTML details element into your content using the details shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
toc: true | ||
--- | ||
|
||
{{< new-in 0.140.0 >}} | ||
|
||
{{% note %}} | ||
To override Hugo's embedded `details` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory. | ||
|
||
[source code]: {{% eturl details %}} | ||
{{% /note %}} | ||
|
||
## Example | ||
|
||
With this markup: | ||
|
||
```text | ||
{{</* details summary="See the details" */>}} | ||
This is a **bold** word. | ||
{{</* /details */>}} | ||
``` | ||
|
||
Hugo renders this HTML: | ||
|
||
```html | ||
<details> | ||
<summary>See the details</summary> | ||
<p>This is a <strong>bold</strong> word.</p> | ||
</details> | ||
``` | ||
|
||
Which looks like this in your browser: | ||
|
||
{{< details summary="See the details" >}} | ||
This is a **bold** word. | ||
{{< /details >}} | ||
|
||
## Arguments | ||
|
||
summary | ||
: (`string`) The content of the child `summary` element rendered from Markdown to HTML. Default is `Details`. | ||
|
||
open | ||
: (`bool`) Whether to initially display the content of the `details` element. Default is `false`. | ||
|
||
class | ||
: (`string`) The `class` attribute of the `details` element. | ||
|
||
name | ||
: (`string`) The `name` attribute of the `details` element. | ||
|
||
title | ||
: (`string`) The `title` attribute of the `details` element. | ||
|
||
## Styling | ||
|
||
Use CSS to style the `details` element, the `summary` element, and the content itself. | ||
|
||
```css | ||
/* target the details element */ | ||
details { } | ||
|
||
/* target the summary element */ | ||
details > summary { } | ||
|
||
/* target the children of the summary element */ | ||
details > summary > * { } | ||
|
||
/* target the content */ | ||
details > :not(summary) { } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
title: Figure | ||
description: Insert an HTML figure element into your content using the figure shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
toc: true | ||
--- | ||
|
||
{{% note %}} | ||
To override Hugo's embedded `figure` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory. | ||
|
||
[source code]: {{% eturl figure %}} | ||
{{% /note %}} | ||
|
||
## Example | ||
|
||
With this markup: | ||
|
||
```text | ||
{{</* figure | ||
src="/images/examples/zion-national-park.jpg" | ||
alt="A photograph of Zion National Park" | ||
link="https://www.nps.gov/zion/index.htm" | ||
caption="Zion National Park" | ||
class="ma0 w-75" | ||
*/>}} | ||
``` | ||
|
||
Hugo renders this HTML: | ||
|
||
```html | ||
<figure class="ma0 w-75"> | ||
<a href="https://www.nps.gov/zion/index.htm"> | ||
<img | ||
src="/images/examples/zion-national-park.jpg" | ||
alt="A photograph of Zion National Park" | ||
> | ||
</a> | ||
<figcaption> | ||
<p>Zion National Park</p> | ||
</figcaption> | ||
</figure> | ||
``` | ||
|
||
Which looks like this in your browser: | ||
|
||
{{< figure | ||
src="/images/examples/zion-national-park.jpg" | ||
alt="A photograph of Zion National Park" | ||
link="https://www.nps.gov/zion/index.htm" | ||
caption="Zion National Park" | ||
class="ma0 w-75" | ||
>}} | ||
## Arguments | ||
|
||
{{< comment >}} | ||
TODO The last thing to do is reword all of these. | ||
{{< /comment >}} | ||
|
||
src | ||
: (`string`) URL of the image to be displayed. | ||
|
||
class | ||
: (`string`) The `class` attribute of the `figure` element. | ||
|
||
alt | ||
: (`string`) Alternate text for the image if the image cannot be displayed. | ||
|
||
loading | ||
: (`string`) The `loading` attribute of the `img` element. | ||
|
||
height | ||
: (`int`) The `height` attribute of the `img` element. | ||
|
||
width | ||
: (`int`) The `width` attribute of the `img` element. | ||
|
||
title | ||
: (`string`) Image title. | ||
|
||
caption | ||
: (`string`) Image caption. Markdown within the value of `caption` will be rendered. | ||
|
||
link | ||
: (`string`) If the image needs to be hyperlinked, URL of the destination. | ||
|
||
target | ||
: (`string`) Applicable if the `link` argument is set, the `target` attribule of the anchor element. | ||
|
||
rel | ||
: (`string`) Optional `rel` attribute for the URL if `link` argument is set. | ||
|
||
attr | ||
: (`string`) Image attribution text. Markdown within the value of `attr` will be rendered. | ||
|
||
attrlink | ||
: (`string`) If the attribution text needs to be hyperlinked, URL of the destination. | ||
|
||
## Image location | ||
|
||
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. | ||
|
||
[page resource]: /getting-started/glossary/#page-resource | ||
[global resource]: /getting-started/glossary/#global-resource | ||
|
||
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: | ||
|
||
{{< code-toggle file=hugo >}} | ||
[[module.mounts]] | ||
source = 'assets' | ||
target = 'assets' | ||
|
||
[[module.mounts]] | ||
source = 'static' | ||
target = 'assets' | ||
{{< /code-toggle >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Gist | ||
description: Embed a GitHub Gist in your content using the gist shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
--- | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: Highlight | ||
description: Insert syntax-highlighted code into your content using the highlight shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
--- | ||
|
||
TODO | ||
|
||
{{% note %}} | ||
With the Markdown [content format], the `highlight` shortcode is rarely needed because, by default, Hugo automatically applies syntax highlighting to fenced code blocks. | ||
|
||
The primary use case for the `highlight` shortcode in Markdown is to apply syntax highlighting to inline code snippets. | ||
|
||
[content format]: /content-management/formats/ | ||
{{% /note %}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Instagram | ||
description: Embed an Instagram post in your content using the instagram shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
--- | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Param | ||
description: Insert a front matter field into your content using the param shortcode. | ||
categories: [shortcodes] | ||
keywords: [] | ||
menu: | ||
docs: | ||
parent: shortcodes | ||
weight: | ||
weight: | ||
--- | ||
|
||
TODO |
Oops, something went wrong.