dsajkdadsa14222 2019-07-22 03:44
浏览 11

范围功能在模板中提供了额外的输出

I am following this link to figure out how to create an archives page. I am using the hugo-xmin theme with slight modifications.

As far as I understand, range goes through the pages and should print them out. But, I am getting an additional 0001 also. I don't understand why. I'm still a beginner to Hugo and Go.

My output (circled portion in red not what I want)

enter image description here

My archives.html

{{ partial "header.html" . }}

<div class="article-meta">
<h1><span class="title">{{ .Title | markdownify }}</span></h1>
{{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
{{ if (gt .Params.date 0) }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end     }}
</div>



<main class="content" role="main">
    <div class="inner">
{{ range (.Site.RegularPages.GroupByDate "2006") }}
<h3>{{ .Key }}</h3>
<ul>
  {{ range (where .Pages "Type" "post") }}
  <li>
    <span class="date">{{ .Date.Format "2006/01/02" }}</span>
    <a href="{{ .RelPermalink }}">{{ .Title }}</a>
  </li>
  {{ end }}
</ul>
{{ end }}
</div>
</main>


{{ partial "footer.html" . }}

My archives.md

---
title: "Archives"
layout: "archives"
draft: false
---

This is archives

My directory structure

.
├── archetypes
│   └── default.md
├── config.toml
├── content
│   ├── about.md
│   ├── archives.md
│   ├── _index.md
│   ├── post
│   │   ├── first_post.md
│   │   ├── sample_code.md
│   │   └── test_math.md
│   └── reading.md
├── data
├── layouts
├── static
└── themes
    └── mytheme
        ├── archetypes
        │   └── default.md
        ├── layouts
        │   ├── 404.html
        │   ├── archives.html
        │   ├── _default
        │   │   ├── archives.html
        │   │   ├── list.html
        │   │   ├── single.html
        │   │   └── terms.html
        │   ├── index.html
        │   └── partials
        │       ├── foot_custom.html
        │       ├── footer.html
        │       ├── head_custom.html
        │       └── header.html
        ├── LICENSE.md
        ├── static
        │   ├── css
        │   │   ├── fonts.css
        │   │   └── style.css
        │   └── js
        └── theme.toml

15 directories, 25 files
  • 写回答

1条回答 默认 最新

  • drpfu51608120170 2019-07-22 04:49
    关注

    I changed my archives.html to the following, with some help from hugo-lithium. It works for my use case now. But I still don't understand why the 0001 came up in the first place. So I will not be marking my answer as correct for now.

    {{ partial "header.html" . }}
    
    <div class="article-meta">
    <h1><span class="title">{{ .Title | markdownify }}</span></h1>
    {{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
    {{ if (gt .Params.date 0) }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end     }}
    </div>
    
    
    {{ range (where .Site.RegularPages "Section" "!=" "").GroupByDate "2006" }}
      <h2>{{ .Key }}</h2>
      <ul>
      {{ range .Pages }}
      <li>
        <span class="date">{{ .Date.Format "2006/02/02" }}</span>
        <a href="{{ .RelPermalink }}">{{ .Title }}</a>
      </li>
      {{ end }}
      </ul>
    {{ end }}
    
    
    
    {{ partial "footer.html" . }}
    
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么