Getting a list of pages with same Date and Lastmod value

Pretty basic, but cannot figure it out:

How to get a list of pages whose date and lastmod value are equal?

My line of thought was:

{{ $pages := where .Site.RegularPages "Date" "Lastmod" }}

You can do it using an if statement:

{{ range .Site.RegularPages }}
  {{ if eq .Date .Lastmod }}
     //output page content
   {{ end }}
{{ end }} 

Note: for .Lastmod to work in this case you should have GitInfo enabled. Otherwise it will default to the .Date.

Thanks for the suggestion. That looks like a good workaround. But in an ideal situation I want to check whether those pages exist first. That way I can have conditional formatting based on it.

In pseudo-code that looks as follows:

{{ $pages := where .Site.RegularPages "Date" "Lastmod" }}

{{ if gt (len $pages) 0 }}

    <!-- All conditional formatting here -->
    {{ range $pages }}
        <!-- Output pages -->
    {{ end }}

{{ end }}

If it isn’t possible then I’ll settle on using two loops: one that counts, and the other from your example that outputs. :slight_smile: