Update Shortcodes doc to add details on Macros for templates (#2035)
This commit is contained in:
parent
4eb3ec82d7
commit
6f29740c18
@ -5,8 +5,7 @@ weight = 40
|
|||||||
|
|
||||||
Zola borrows the concept of [shortcodes](https://codex.wordpress.org/Shortcode_API) from WordPress.
|
Zola borrows the concept of [shortcodes](https://codex.wordpress.org/Shortcode_API) from WordPress.
|
||||||
In our case, a shortcode corresponds to a template defined in the `templates/shortcodes` directory or
|
In our case, a shortcode corresponds to a template defined in the `templates/shortcodes` directory or
|
||||||
a built-in one that can be used in a Markdown file. If you want to use something similar to shortcodes in your templates,
|
a built-in one that can be used in a Markdown file.
|
||||||
try [Tera macros](https://tera.netlify.com/docs#macros).
|
|
||||||
|
|
||||||
Broadly speaking, Zola's shortcodes cover two distinct use cases:
|
Broadly speaking, Zola's shortcodes cover two distinct use cases:
|
||||||
|
|
||||||
@ -18,6 +17,8 @@ The latter may also be solved by writing HTML, however Zola allows the use of Ma
|
|||||||
rather than `.html`. This may be particularly useful if you want to include headings generated by the shortcode in the
|
rather than `.html`. This may be particularly useful if you want to include headings generated by the shortcode in the
|
||||||
[table of contents](@/documentation/content/table-of-contents.md).
|
[table of contents](@/documentation/content/table-of-contents.md).
|
||||||
|
|
||||||
|
If you want to use something similar to shortcodes in your templates, you can use [Tera macros](https://tera.netlify.com/docs#macros). They are functions or components that you can call to return some text.
|
||||||
|
|
||||||
## Writing a shortcode
|
## Writing a shortcode
|
||||||
Let's write a shortcode to embed YouTube videos as an example.
|
Let's write a shortcode to embed YouTube videos as an example.
|
||||||
In a file called `youtube.html` in the `templates/shortcodes` directory, paste the
|
In a file called `youtube.html` in the `templates/shortcodes` directory, paste the
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user