hugopartialshugo-theme

Integrating code via partials on a Hugo site not working


I am running an open source comment engine on my server which I want to integrate to my Hugo site.

After doing all the listed things below, the comment section is not visible, and only the heading appears.

What are the possible reasons for this and error and how can I solve it?

So I created a partials file for It, added some code in single.hmtl and edited my config.toml correspondingly.

This is what's inside my partial file named commento.html:

<div id="commento"></div>
<script defer src="{{ .Site.Params.CommentoURL }}/js/commento.js"></script>
<noscript>Please enable JavaScript to load the comments.</noscript>

This is what's inside my single.html file:

{{ if and .Site.Params.CommentoURL (and (not .Site.BuildDrafts) (not .Site.IsServer)) -}}
<h2>Comments</h2>
{{ partial "commento.html" . }}
{{- end }}

and I added the commentoURL parameter in config.toml file like this:

CommentoURL = "http://qwerty.abc:8080"

Solution

  • Please Inspect the output HTML. I am pretty sure you will find this empty div:

    <div id="commento"></div>
    

    This means that your Javascript is broken. This has nothing to do with Hugo, partials or even Hugo themes. You probably also have a red error in your Javascript console. This is what you should focus on.