How to include config.toml for reading?

Hello everyone,

I have added comments to my config.toml.
In the documentaion of the website I want to include this config.toml as source file for viewing.
I use the shortcode include-as-code.html.
Why does the output appear as (partially) rendered markdown instead of source code?
What am I doing wrong?

Many thanks for your time and best regards

Shortcode `include-as-code.html`

{{ $file := .Get 0 }}
{{ $plain := print ($file | readFile) }}

<figure>
<pre><code>
{{ $plain }}
</code></pre>
<figcaption>
Quelldatei: {{ $file }}
</figcaption>
</figure>

config.toml

#
# ra-master
# hugo 0.92.1
#

#baseURL = "http://localhost:1313/"
baseURL = ""

languageCode = "de"

#relativeURLs = "false"
relativeURLs = "true"

uglyURLs = "true"
#uglyURLs = "false"

theme = "ra-master"
title = "ra-master"

# enableInlineShortcodes ermöglicht die Nutzung von Code direkt in der Contentdatei
# Syntax: {{< time.inline >}}{{ now }}{{< /time.inline >}}
enableInlineShortcodes = true

# enableEmoji ermöglicht die Nutzung von Emojis "I :heart: you!"
# Verfübare Emojis: `https://www.webfx.com/tools/emoji-cheat-sheet/`
enableEmoji = true

# Selbstdefinierte Parameter, Variablen, Daten oder was auch immer
[params]
testvariable = "Inhalt der site-weiten Testvariablen aus config.toml."

[markup.goldmark.renderer]
# unsafe ermöglicht die Nutzung von HTML in der Contentdatei
unsafe = true

# Einstellung ermöglicht das Anhängen von Klassen mittels {{ .myClass }} an Überschriften und Blockelemente
[markup.goldmark.parser.attribute]
block = true
title = true

[taxonomies]
tag = "tags"

[outputs]
home = ["HTML", "RSS", "JSON"]

</details>

Output

Please show your markup.

What do you mean by “markup”?

How are you calling the shortcode?

Thanks @jmooring,

your question led me to the solution…

I had the shortcode using {% include-as-code "./config.toml " %}}, this rendered the file contents.
When I call the Shortcode using {< include-as-code "./config.toml " >}}, everything works as it should and the file content is displayed unrendered.

Many greetings

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.