Grouping and sorting archives by year and month

I’m 100% positive the issue is the quotes around the date in the above post. I edited it to fix.

This diff should show how it would work https://github.com/jsonbecker/theme-ink/pull/1/files

Thanks. This made sense. However, I don’t know why it doesn’t work on the Ink theme. I like how you have done it on your homepage. Date in a larger font with hyperlinked timestamp. Also, I like how if your post has a title, it still displays in full although most of my posts, micro or macro may not have titles.

Wish I could steal that :slight_smile:

That’s all a part of the post-partial and how it works. I’ve never really tried to make my theme not super specific to me, but I could look into it if there’s interest.

I think the structure of post-partial and the surrounding HTML would have to be adjusted. Just for comparison, here’s what my index page looks like:

{{ define "main" }}  
{{ $posts := where .Site.Pages "Type" "post" }}
{{ $grouped := $posts.GroupByDate "2006-01-02" }}
{{ $paginated := (.Paginate ($grouped)) }}
<div class="content list h-feed">
{{ range $paginated.PageGroups }}
{{ $thedate := (time .Key) }}
<h1 class="day"> {{ $thedate.Format "January 2, 2006" }}</h1>
{{ range .Pages.Reverse }}
    {{ if eq .Type "post" }}
<article class = "h-entry">
 <div class="title-area">
       {{ if .Title }}
        <h2 class = "p-name  post-title">
          <a class = "u-url" href = "{{ .Permalink }}">{{ .Title }}</a>
        </h2>
        {{ end }}
    <time class = "date dt-published" datetime = "{{ .Date.Format "January 02, 2006 15:04:05  -0700" }}" {{ if not .Title }} style="justify-content:flex-end;" {{ end }}>
      <a class = "u-url" href = "{{ .Permalink }}">{{ .Date.Format "3:04PM" }} </a>
    </time>
</div>
       <div class = "post-content e-content">
         {{ .Content }}
       </div>
     {{ partial "post_footer.html" . }}
    {{- end }}
  {{ end }}
{{ end }}
 </div>
{{ partial "paginator.html" . }}
{{ end }}

Yup, I think I’ve reached the end of my current capabilities. I tried modifying the code in the index page but as you said, it may need adjusting elsewhere. I wish I could modify it for the existing MB themes (Ink, Lanyon, etc.) coz those suit the way I blog (similar to yours).

If you ever think of porting such a theme, color me interested. I think David (@crossingthethreshold) may also be interested.

It’s lunchtime here and I’m just checking in to see where things are at. Looking at what @pratik has done, I don’t think that I would be capable to do anymore. I also like how the post timestamps work on your site @jsonbecker. I might still tinker, but I would be interested if you, Jason, do port a theme like yours.

Thank you for all of your help.

I built a test archive to match the original post, btw. (hi @pimoore )

Check this

layouts/archive/single.html

{{ define "main" }}
{{$pages := where .Site.Pages "Type" "post" }}
  {{ range $pages.GroupByDate "2006" }}
        <div class="group">
            <h2 class="key">
                {{ .Key }}
            </h2>
            {{ range .Pages.GroupByDate "January" }}
               <h3 class="key">
                {{ .Key }}
                </h3>
             {{ range .Pages }}
              {{ partial "li.html" . }}
            {{ end }}
   {{ end }}
{{ end }}
{{ end }}

content/testarchive.md

---
title: History
description: Archive of posts
type: archive
---

To make this show up in /archive you’ll have to delete that page from the micro.blog interface and rename content/testarchive.md to content/archive.md.

1 Like

Oh that’s perfect, exactly what I was looking for! I’m also doing some thinking around various layouts for the index page posts, including your setup, with relation to themes. I’m not a huge fan of having the index page just be a pagination through the whole site, and I much prefer how Hitchens is implemented in this regard compared to Tufte.

I like the index being just the recent or current day’s posts, or even just a single post like I’ve seen on many with a link to the archive instead. I’m also looking into a couple of ideas @JohnPhilpin mentioned around date links, and setting them up to show all the posts for that date as opposed to that specific post only.

1 Like

:nerd_face:

cockles duly warmed !

1 Like

Pretty easy to do that on the index page-- but the date links are actually very tricky on Hugo.

What makes them so challenging out of curiosity?

Hugo doesn’t really have a great way of generating pages from your post data-- it either wants to show a collection on a page based on your filtering or show a single one on a page, but the idea of generated paths and files that have lists with filters in an automated way is not really a supported use case. Lots of stuff on the Hugo forums about this-- but there’s no way to tell Hugo make a folder like /yyyy/mm and there filter to those posts. The only way I think this can be done is making custom pages for every /yyyy/mm you have, add those as page parameters in the front matter, then filter posts to that.

1 Like

It’s just that Hugo lacks support for easily implementing this. There’s actually an open issue since 2014.

There are workarounds, like Using Taxonomies to Create Monthly Archives in Hugo. (The same technique could be used to create daily archives.)

Another workaround would be to solve it on the client-side, using JavaScript.

1 Like

@crossingthethreshold @pratik I haven’t made it responsive and I need to do some work to make it more parameterizable etc (some things here don’t work because I don’t maintain my test blog), but this is what I’ve got for a new theme so far if you’d like to peek/provide feedback.

It’s a ground up rewrite for me that’s meant to be turned into a plug-in theme eventually.

2 Likes

This looks great, Jason. Currently, I’m using Amit’s Musing theme for the chronological within-day sorting and have made some tweaks, as you may have seen. I love the sans serif and strong colors in your theme that highlight the day separation. The photo embeds are currently broken in the gallery so like to see that with your Light plugin enabled (hope that’s built in support). I’m a big fan of footnotes so also love your Bigfoot.

Possible to add a subtitle for the theme? Also, now I think I prefer the wide width for the text instead of the narrow one that I have on my blog now.

Would love to test it out once you can share.

Yeah the images and glightbox will work— I just don’t have it installed on my test blog and the images that post references have moved. Where would you put the subtitle?

In a smaller font size below the title.

This does look good. Thank you for your efforts. Like @pratik, the sans serif font works well for me. I notice, where I can sans serif fonts are my preference.

@pimoore - is this part of your long weekend project?

It could be… :wink: