# Adding "uniq" to template functions

**URL:** <https://discourse.gohugo.io/t/adding-uniq-to-template-functions/6710>\
**Category:** dev\
**Created:** [May 25, 2017, 12:19am UTC](https://discourse.gohugo.io/t/adding-uniq-to-template-functions/6710 "2017-05-25T00:19:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adiabatic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/adiabatic/32/2913_2.png) [@adiabatic](https://discourse.gohugo.io/u/adiabatic)\
**Post date:** [May 25, 2017, 12:19am UTC](https://discourse.gohugo.io/t/adding-uniq-to-template-functions/6710/1 "2017-05-25T00:19:09Z")

</div>

One of the reasons I haven’t moved my site over to Hugo is that I was getting duplicate breadcrumbs entries on my blog’s back pages (/blog/page/2/, /blog/page/3/, etc.). Recently I figured that I could solve my problem well enough if there were a `uniq` function to throw out the duplicate entries in the list of parent pages. There wasn’t one, so I [made one](https://github.com/spf13/hugo/compare/master...adiabatic:master).

I’ll be the first to admit that I don’t know what I’m doing with `reflect`, but it seems to work well for the tests I adapted from `TestUnion()` and it does what I want it to on my site. I’m not sure what’s next: I watch spf13/hugo on Github and it seems like most of the conversations there have a second post that says “discuss this on the forums first”, so I’m opening the conversation here. I’d be happy to submit a pull request and make any changes needed to make this Hugo-quality.

---

<div class="post-metadata">

**Author:** ![adiabatic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/adiabatic/32/2913_2.png) [@adiabatic](https://discourse.gohugo.io/u/adiabatic)\
**Post date:** [May 25, 2017, 2:43pm UTC](https://discourse.gohugo.io/t/adding-uniq-to-template-functions/6710/2 "2017-05-25T14:43:58Z")

</div>

I was about to do the `git rebase -i` dance to squash my four commits, but Git told me that I had uncommitted changes that needed to be stashed before I could do that. My `vendor/vendor.json` changed a bit and I’m not sure what’s going on. I’m pretty sure I ran `make vendor` when hugo was in `$GOPATH/src/hugo` instead of `$GOPATH/src/github.com/spf13/hugo`, but I don’t know if I should worry about the SHA1 differences. Here’s the diff of what my `vendor/vendor.json` looks like now:

```
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 73cb86a8..59c73725 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -359,19 +359,19 @@
            "revisionTime": "2017-05-22T23:30:54Z"
        },
        {
- "checksumSHA1": "wxrHmKhFznZZAjrYK5/nWn+fZGc=",
+ "checksumSHA1": "4owIzLmRdrdy3H3j/OD8UMJD5ZE=",
            "path": "golang.org/x/sys/unix",
            "revision": "dbc2be9168a660ef302e04b6ff6406de6f967473",
            "revisionTime": "2017-05-20T17:05:02Z"
        },
        {
- "checksumSHA1": "DoQpPb6ZhqN2gP7rNXfxHaTUgEs=",
+ "checksumSHA1": "DWHpSSH7hmB31XvpQqFDshcRU+4=",
            "path": "golang.org/x/text/cases",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
        },
        {
- "checksumSHA1": "9Px0J1fbo4RT0sxn40pPUZOEdhM=",
+ "checksumSHA1": "A9N3+Wl4MedhMJZIlun1LXXCCNI=",
            "path": "golang.org/x/text/internal",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
@@ -383,7 +383,7 @@
            "revisionTime": "2017-04-21T08:09:44Z"
        },
        {
- "checksumSHA1": "Dhc7bHUc+d1uuYO/byxQf7AfW+o=",
+ "checksumSHA1": "ckawpDnd22U/0HjSPKF4yY5pIeg=",
            "path": "golang.org/x/text/language",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
@@ -401,7 +401,7 @@
            "revisionTime": "2017-04-21T08:09:44Z"
        },
        {
- "checksumSHA1": "cvRGMfzfSIW0uZ9V2Px24q512Ks=",
+ "checksumSHA1": "xO6ERghp1RGU9RM2t6ykY0cK1g0=",
            "path": "golang.org/x/text/secure/precis",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
@@ -413,19 +413,19 @@
            "revisionTime": "2017-04-21T08:09:44Z"
        },
        {
- "checksumSHA1": "KG+XZAbxdkpBm3Fa3bJ3Ylq8CKI=",
+ "checksumSHA1": "MRLtTu/vpd18le8/HPLxOdjO5RE=",
            "path": "golang.org/x/text/unicode/bidi",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
        },
        {
- "checksumSHA1": "Anof4bt0AU+Sa3R8Rq0KBnlpbaQ=",
+ "checksumSHA1": "kKylzIrLEnH8NKyeVAL0dq5gjVQ=",
            "path": "golang.org/x/text/unicode/norm",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
        },
        {
- "checksumSHA1": "/kqvbsH5mRknhs6xf7cJii0wQos=",
+ "checksumSHA1": "aCXemG0knLp8YJedta7fYAIiX/8=",
            "path": "golang.org/x/text/width",
            "revision": "19e51611da83d6be54ddafce4a4af510cb3e9ea4",
            "revisionTime": "2017-04-21T08:09:44Z"
@@ -437,5 +437,5 @@
            "revisionTime": "2017-04-07T17:21:22Z"
        }
    ],
-	"rootPath": "github.com/spf13/hugo"
+	"rootPath": "hugo"
 }
```

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [June 1, 2017, 3:01am UTC](https://discourse.gohugo.io/t/adding-uniq-to-template-functions/6710/3 "2017-06-01T03:01:40Z")

</div>

Hi. Did you get a response to your pull request?

---

<div class="post-metadata">

**Author:** ![adiabatic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/adiabatic/32/2913_2.png) [@adiabatic](https://discourse.gohugo.io/u/adiabatic)\
**Post date:** [June 1, 2017, 3:12am UTC](https://discourse.gohugo.io/t/adding-uniq-to-template-functions/6710/4 "2017-06-01T03:12:36Z")

</div>

Yup. After a bit of back-and-forth making the pull request better, it’s been integrated into the `main` branch on `spf13/hugo`.
