.Kind (page): .Type (posts) / .Layout ()
Bundle: n/a (regular page)
[ categories | tags | search ]
ox-hugo Test Site

This is the test site for the ox-hugo package for Emacs/Org-mode.

It is updated automatically after each commit to the ox-hugo repo. It was last updated on Jun 26, 2022 21:18 UTC.

This page was created/modified in commit 4f6517d "fix: Escape Hugo shortcodes in description front-matter" on 2022-05-31.
Markdown source of this page

Markdown source block with Hugo shortcodes

tags: src-block shortcode


Test verbatim use of Hugo shortcodes in content.


Shortcodes escaped #

The figure shortcodes in the two Markdown source code blocks below should not be expanded.. they should be visible verbatim.

Code block using code fences #

{{< figure src="https://ox-hugo.scripter.co/test/images/org-mode-unicorn-logo.png" >}}
{{% figure src="https://ox-hugo.scripter.co/test/images/org-mode-unicorn-logo.png" %}}

Code block using code fences with line numbering enabled #

Here, the -n switch is added to the Org source block to enable line numbering.

{{< figure src="https://ox-hugo.scripter.co/test/images/org-mode-unicorn-logo.png" >}}
{{% figure src="https://ox-hugo.scripter.co/test/images/org-mode-unicorn-logo.png" %}}

Shortcode escaped in Org source blocks #

#+macro: relref @@hugo:[@@ $1 @@hugo:]({{< relref "$2" >}})@@

Shortcodes not escaped #

The figure shortcode in the below example block should be expanded.. you should be seeing a little unicorn below.

Above a #+begin_example .. #+end_example block is chosen arbitrarily. The Hugo shortcodes will remain unescaped in any source/example block except for Markdown source blocks (annotated with md language).

Below, the same figure shortcode is called with the % syntax.

If you are using Hugo 0.55.0 or newer, you will just see the raw HTML from this shortcode (unrendered HTML) because the behavior of {{% .. %}} shortcodes changed in Hugo v0.55.0.
<figure><img src="https://ox-hugo.scripter.co/test/images/org-mode-unicorn-logo.png"/>

It is necessary to set the Hugo site config variable markup.highlight.codeFences to true (default) for syntax highlighting to work for fenced code blocks.

Page (Debug)

Page VariableValue
Name "Markdown source block with Hugo shortcodes"
Title "Markdown source block with Hugo shortcodes"
ResourceType "page"
Kind "page"
Section "posts"
Draft false
Type "posts"
Layout ""
Permalink "https://ox-hugo.scripter.co/test/posts/source-block-md-with-hugo-shortcodes/"
RelPermalink "/posts/source-block-md-with-hugo-shortcodes/"
page.Data{} (type:page.Data)
NextPageMake the author front-matter plural
PrevPageMarkup Front-matter
NextInSectionMake the author front-matter plural
PrevInSectionMarkup Front-matter

Page Params (Debug)

descriptionstring "Test verbatim use of Hugo shortcodes in content."
draftbool false
iscjklanguagebool false
lastmodtime.Time 2022-05-31 17:36:16 -0400 -0400
tags[]string "src-block" "shortcode"
titlestring "Markdown source block with Hugo shortcodes"

File Object (Debug)

FileInfo VariableValue
UniqueID "7920471648f1003dde3ab430a09700c0"
BaseFileName "source-block-md-with-hugo-shortcodes"
TranslationBaseName "source-block-md-with-hugo-shortcodes"
Lang "en"
Section "posts"
LogicalName "source-block-md-with-hugo-shortcodes.md"
Dir "posts/"
Ext "md"
Path "posts/source-block-md-with-hugo-shortcodes.md"

This site is generated using the ox-hugo package for Emacs/Org-mode + hugo-bare-min-theme + Hugo 0.101.0 (commit 466fa43c16709b4483689930a4f9ac8add5c9f66) . This site is powered by Netlify.
[Test Site home | ox-hugo home]