在hugo学术主题中自定义"关于"小部件

Rob*_*llo 3 r hugo blogdown

我通过RStudio/blogdown使用hugo-academic主题来构建我的网页.示例页面位于:https://themes.gohugo.io/theme/academic/

我想在学术界之下添加第二份非学术兴趣列表.这可能吗?

在配置部分中about.md有一个列表

# List your academic interests.
 [interests]
   interests = [
     "Artificial Intelligence",
     "Computational Linguistics",
     "Information Retrieval"
   ]
Run Code Online (Sandbox Code Playgroud)

但我不确定它是如何传递给实际构建网站的进程.本着"只是添加东西以查看它是否有效"的精神,我尝试添加另一个[other_interests]部分但它似乎没有做任何事情.

Jem*_*s42 5

您可以添加另一个兴趣列表,但主题不知道您添加的列表.在主题的源代码中,您将找到此部分:

  {{ with $page.Params.interests }}
  <div class="col-sm-5">
    <h3>{{ i18n "interests" | markdownify }}</h3>
    <ul class="ul-interests">
      {{ range .interests }}
      <li>{{ . }}</li>
      {{ end }}
    </ul>
  </div>
  {{ end }}
Run Code Online (Sandbox Code Playgroud)

https://github.com/gcushen/hugo-academic/blob/master/layouts/partials/widgets/about.html#L50-L59

其中,基于预定义列表呈现HTML部分.
您可以尝试复制/粘贴此部分并更改interests为您的内容other_interests并查看其进展情况:

  {{ with $page.Params.other_interests }}
  <div class="col-sm-5">
    <h3>{{ i18n "interests" | markdownify }}</h3>
    <ul class="ul-interests">
      {{ range .other_interests }}
      <li>{{ . }}</li>
      {{ end }}
    </ul>
  </div>
  {{ end }}
Run Code Online (Sandbox Code Playgroud)

我建议在雨果中阅读模板,以便更好地了解那里发生的事情.如果您有更多特定于此主题的问题,那么源GitHub存储库可能是一个很好的起点.