Best way to “include” code snippets in Homepage?

I am documenting my company’s software. We have sample HTML and Javascript code.

I have some issues to include code snippets in the Homepage.

I don’t want the code to run or anything, I just want it to show up on homepage.

Have someone already made this happen ?


I’m sure we can figure this out, but I need a bit more information about the issues you are having. If you can point me to a repo, that would be even better…

{{ if .IsHome )}}
        <script src=""></script>
{{ end }}

I don’t want the code to run or anything, I just want it to show up on homepage. - Do you need to include code in your documentation (markdown code block?), or are you trying to only include jQuery if .IsHome?

The question is rather confusing.

thank to @rdwatters in this topic Embedding multiple markdown files into homepage

I just write a bunch of markdown in a partial and then add markdownify after calling the partial.

So,i create layouts/partials/codes/columns.html:

<div class="columns">
  <div class="column">1</div>
  <div class="column">2</div>
  <div class="column">3</div>
  <div class="column">4</div>
  <div class="column">5</div>

Then in layouts/index.html i call:

{{partial "codes/columns.html" . |  markdownify }}

And i get the following output:

<pre><code class="language-html">&lt;div class="columns"&gt;
  &lt;div class="column"&gt;1&lt;/div&gt;
  &lt;div class="column"&gt;2&lt;/div&gt;
  &lt;div class="column"&gt;3&lt;/div&gt;
  &lt;div class="column"&gt;4&lt;/div&gt;
  &lt;div class="column"&gt;5&lt;/div&gt;

I have also a syntax highlighting in client side (I set up highlighting.js as described in the Hugo documentation site:).

Is there other alternative to do that with syntax highlighting ?