# Get unique committers in hugo

**URL:** <https://discourse.gohugo.io/t/get-unique-committers-in-hugo/9369>\
**Category:** support\
**Created:** [November 26, 2017, 1:47am UTC](https://discourse.gohugo.io/t/get-unique-committers-in-hugo/9369 "2017-11-26T01:47:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddhantrimal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/siddhantrimal/32/4392_2.png) [@siddhantrimal](https://discourse.gohugo.io/u/siddhantrimal)\
**Post date:** [November 26, 2017, 1:47am UTC](https://discourse.gohugo.io/t/get-unique-committers-in-hugo/9369/1 "2017-11-26T01:47:02Z")

</div>

## I did

this:

```auto
    {{ if and (or .IsPage .IsSection) .Site.Params.contentCommitsURL }}
         {{ $File := .File }}
         {{ $Site := .Site }}
         {{with $File.Path }}
         {{ $fileDir := replace $File.Dir "\\" "/"}}
              {{ $url := $File.LogicalName | printf "%s%s" $fileDir | printf "%s%s" $Site.Params.contentCommitsURL }}
              {{ $.Scratch.Set "url" $url }}
         {{ end }}
    {{ end }}

    {{ $url := $.Scratch.Get "url"}}
    {{ range getJSON $url }}
    <div style="display:inline-block; width:40px;">
      <a href="{{.author.html_url}}" target="_blank">
        <img src="{{.author.avatar_url}}" alt="{{.author.login}}" text="{{.author.login}}" class="inline" width="40" height="40" style="height: 40px;height: 40px; vertical-align:middle; margin: 0 auto;">
      </a>
    </div>
    {{ end }}

```

to achieve an equivalent of this:

```auto
const githubAPI = "https://api.github.com"
const commitsEndpoint = "/repos/csitauthority/CSITauthority.github.io/commits"
const commitsURL = githubAPI + commitsEndpoint
const filepath = "HUGO/content/post/vlan-101.md"
fetch(commitsURL + "?path=" + filepath)
  .then(response => response.json())
  .then(commits => {
    for (var i = 0; i < commits.length; i++) {
      console.log(commits[i].commit.author.name)
    }
  })

```

* * *

## What would be an equivalent, in HUGO, for the following?

```auto
const githubAPI = "https://api.github.com"
const commitsEndpoint = "/repos/csitauthority/CSITauthority.github.io/commits"
const commitsURL = githubAPI + commitsEndpoint
const filepath = "HUGO/content/post/grandfather-problem.md"
fetch(commitsURL + "?path=" + filepath)
  .then(response => response.json())
  .then(commits => {
    const names = [];
    for (var i = 0; i < commits.length; i++) {
      if (!names.includes(commits[i].commit.author.name)) {
        names.push(commits[i].commit.author.name);
      }
    }
    console.log(names.join("\n"));
  })

```

## I am trying to

1. show all the commits made to a file(_ **post** _, _actually_) when I post.
2. The committer must be unique. ie. No committer should show up more than once (the js above satisfies this rule)

## Screenshots _SCROLL THIS WAY_ **---------------------\>\>**

| What’s happening now | What I’m trying to achieve |
| --- | --- |
| ![](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/2/21e39f8f40f4ea0ceeece4a6ea19e35cf84eec1f.PNG) | ![](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/2/2815397edfe216aaf0d66561195a8686ccf4ae72.jpg) |

---

<div class="post-metadata">

**Author:** ![RickCogley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rickcogley/32/10269_2.png) [@RickCogley](https://discourse.gohugo.io/u/RickCogley)\
**Post date:** [November 26, 2017, 3:06am UTC](https://discourse.gohugo.io/t/get-unique-committers-in-hugo/9369/2 "2017-11-26T03:06:09Z")

</div>

I know you can get the latest commit natively with Hugo. As for the history it might need a script to grab that from the git log, then put it in a manifest, under data, to then access later in templates.

This is something I made before it was baked in to Hugo.

> [@Put latest git info in an HTML comment](https://discourse.gohugo.io/t/put-latest-git-info-in-an-html-comment/2773):
>
> It was not really an urgent need, but I thought it would be nice to get the git info for a given content .md file, and put that into an HTML comment, inside the \<head\> section. More or less for better troubleshooting. Here’s how to do it. Rejected solution There’s one method I tried, which I abandoned, because of dependency on OS environment variables. This is the bash script snippet for that, which creates a bunch of environment variables: for f in /dev/path/to/content/post/.md; do export $(b…

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [November 26, 2017, 3:28am UTC](https://discourse.gohugo.io/t/get-unique-committers-in-hugo/9369/3 "2017-11-26T03:28:48Z")

</div>

See the [solution to a similar problem](https://discourse.gohugo.io/t/count-content-based-on-front-matter-variable/8719/16?u=moorereason).
