Customizing the Archive page
The Archive pages in my blogs show a list of every post I’ve published. Their titles, if they have them, and the first 150 characters of their content. I didn’t like how they looked in Tiny Theme, I wanted a cleaner look, so I changed the layouts/_default/list.archivehtml.html
both in blog.estebantxo.com
and in social.estebantxo.com
.
This is the original template, that I keep here as backup:
{{ define "main" }}
<div class="archive">
<h2 class="p-name">Archive</h2>
{{ if templates.Exists "partials/microhook-archive-lead.html" }}
{{ partial "microhook-archive-lead.html" . }}
{{ end }}
{{ $list := ($.Site.GetPage "taxonomyTerm" "categories").Pages }}
{{ if gt (len $list) 0 }}
<div class="archive-categories">
<h3>Categories</h3>
<ul>
{{ range $list }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
</div>
{{ end }}
<div class="full-archives h-feed">
<h3>Full Post List</h3>
{{ $list := (where .Site.Pages "Type" "post") }}
{{ range $list }}
<p class="h-entry">
<a href="{{ .Permalink }}" class="u-url"><span class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05-0700" }}">{{ .Date.Format "Jan 2, 2006" }}</span></a>:
{{ if .Title }}
<span class="p-name"><b>{{ .Title }}</b></span>
{{ end }}
<span class="p-summary">{{ .Summary | truncate 150 }}</span>
</p>
{{ end }}
</div>
</div>
{{ end }}
For blog.estebantxo.com
I want to show the titles only, without a summary of the contents, so I delete or comment this whole line: <span class="p-summary">{{ .Summary | truncate 150 }}</span>
.
To comment out some code, I place it between this two wrappers: {{/* comment */}}
.
For social.estebantxo.com
, since the microposts don’t usually have a title, I just reduce the length of the summary, to 50 characters instead of 150. Here: <span class="p-summary">{{ .Summary | truncate 50 }}</span>
.