I encountered a weird issue when trying to display subsection titles on a list page. Compared to single pages in this theme (which is hugo-coder), the text on the list page and its subpages (as shown in the picture below) is too small and too much to the left. Another issue is that content in /content/projects/_index.md
didn’t render at all.
The only thing I did was to add a list.html
file in /layouts/projects
. Why would this happen and how can I render the theme properly on a list page? Thanks!! (GitHub)
{{ define "title" }}
{{ .Title }} · {{ .Site.Title }}
{{ end }}
{{ define "content" }}
{{ if (eq $.Parent.Title "Projects") }}
<ul class="no-bullet">
{{ range .Paginator.Pages }}
{{ .Render "li" }}
{{ end }}
</ul>
{{ partial "pagination.html" . }}
{{ else }}
{{ range (where .Site.Pages "Section" "projects") }}
<ul class="no-bullet">
{{ range .Sections }}
<li>
<span class="date">{{ .Date.Format (.Site.Params.dateFormat | default "January 2, 2006" ) }}</span>
<a class="title" href="{{ .Params.ExternalLink | default .RelPermalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ end }}
Original post:
Under /content/projects
, I have two separate categories, cs
and ds
. I wish to create a list page that displays the names of these two categories along with the URL to both. I know people asked similar questions before. However, none of the solutions I tried worked for me.
Below are my folder structure (relevant folders only) and the original code in /layouts/_default/list.html
and /layout/partial/list.html
. Which files should I modify and how in order to display subsections correctly? Thank you so much!!
In /layouts/_default
:
{{ define "title" }} {{- if eq .Kind "taxonomy" -}}
{{- i18n .Data.Singular | title -}}
{{- print ": " -}}
{{- end -}}
{{- .Title }} · {{ .Site.Title -}}
{{ end }}
{{ define "content" }}
{{ partial "list.html" . }}
{{ end }}
In /layouts/partial
:
<section class="container list">
<h1 class="title">
{{- if eq .Kind "taxonomy" -}}
{{- i18n .Data.Singular | title -}}
{{- print ": " -}}
{{- end -}}
{{- .Title -}}
</h1>
{{ .Content }}
<ul>
{{ range .Paginator.Pages }}
<li>
<span class="date">{{ .Date.Format (.Site.Params.dateFormat | default "January 2, 2006" ) }}</span>
<a class="title" href="{{ .Params.ExternalLink | default .RelPermalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ partial "pagination.html" . }}
</section>
Folder structure of content
and layout
:
├── content
│ ├── about.md
│ ├── posts
│ │ └── amazon.md
│ └── projects
│ ├── _index.md
│ ├── cs
│ │ ├── _index.md
│ │ └── covid19.md
│ └── ds
│ ├── _index.md
│ └── covid19.md
├── layouts
│ ├── 404.html
│ ├── _default
│ │ ├── baseof.html
│ │ ├── list.html
│ │ └── single.html
│ ├── index.html
│ ├── partials
│ │ ├── 404.html
│ │ ├── analytics
│ │ │ └── fathom.html
│ │ ├── footer.html
│ │ ├── header.html
│ │ ├── home.html
│ │ ├── list.html
│ │ ├── page.html
│ │ ├── pagination.html
│ │ ├── posts
│ │ │ ├── commento.html
│ │ │ ├── disqus.html
│ │ │ ├── math.html
│ │ │ ├── series.html
│ │ │ └── utteranc.html
│ │ └── taxonomy
│ │ ├── categories.html
│ │ └── tags.html
│ ├── posts
│ │ ├── li.html
│ │ ├── list.html
│ │ └── single.html
│ └── projects
│ └── list.html
...