【问题标题】:Integrating code via partials on a Hugo site not working通过 Hugo 站点上的部分代码集成代码不起作用
【发布时间】:2023-02-20 16:27:42
【问题描述】:

我在我的服务器上运行一个开源评论引擎,我想将其集成到我的 Hugo 站点。

完成下面列出的所有操作后,评论部分不可见,只有标题出现。

这和错误的可能原因是什么,我该如何解决?

所以我创建了一个部分文件为此,在single.hmtl中添加了一些代码并相应地编辑了我的config.toml

这是我名为 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>

这是我的 single.html 文件中的内容:

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

我在 config.toml 文件中添加了 commentoURL 参数,如下所示:

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

【问题讨论】:

    标签: hugo partials hugo-theme


    【解决方案1】:

    请检查输出的 HTML。我很确定你会发现这个空的 div:

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

    这意味着您的 Javascript 已损坏。这与 Hugo、partials 甚至 Hugo 主题无关。您的 Javascript 控制台中也可能出现红色错误。这是你应该关注的。

    【讨论】:

      猜你喜欢
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-14
      • 1970-01-01
      • 2019-04-23
      • 2023-03-07
      • 1970-01-01
      相关资源
      最近更新 更多