"Recently Edited" section, with GitHub links for Commit Diff and File History

As an update to this post, which strayed into troubleshooting issues, I am sharing here an update I just did when I found how GitHub lets you link to the History of a file (a subtle difference between commit and commits in the URL).

So to have a Recently Edited section in your site that looks like this

[I know, those icons look misaligned, if somebody has a tip to fix that I’d appreciate it]

You can get all this information from Hugo’s --enableGitInfo option, and corresponding GitInfo variables.

This is the code that drives the loop (from here):

<h2>{{ T "RecentlyEdited"}}</h2>
<h4 class="hd">{{ T "DocumentationPages"}}</h4>
<div class="edit_wrap">
    {{ $byLastMod :=  .Site.RegularPages.ByLastmod  }}
    {{ $recent := ($byLastMod | last 5).Reverse }}
    {{ partial "recently-edited-item" $recent }}

And this is the interesting part writing out each item (from here):

{{ range  . }}
	<h4 class="">
	    <a href="{{ .Permalink }}">{{ .Title }}</a>
            <a href="https://github.com/salesagility/SuiteDocs/commits/{{.GitInfo.Hash}}/content/{{.Path}}" target="_blank" title="File History"><i class="fa fa-2x fa-history"></i></a>
	<p class="">
	   Edited on the {{ .Lastmod.Format "2 January" }} in commit <b>"{{ with .GitInfo }}{{ .Subject }}{{ else }}[Commit description]{{ end }}"</b>  
             <a href="https://github.com/salesagility/SuiteDocs/commit/{{.GitInfo.Hash}}" target="_blank" title="Commit Diff"><i class="fa fa-2x fa-github"></i></a>
{{ end }}