# How to use GroupByParam with param subkeys?

**URL:** <https://discourse.gohugo.io/t/how-to-use-groupbyparam-with-param-subkeys/48929>\
**Category:** support\
**Created:** [March 19, 2024, 1:43pm UTC](https://discourse.gohugo.io/t/how-to-use-groupbyparam-with-param-subkeys/48929 "2024-03-19T13:43:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![riskysnail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/riskysnail/32/21637_2.png) [@riskysnail](https://discourse.gohugo.io/u/riskysnail)\
**Post date:** [March 19, 2024, 1:43pm UTC](https://discourse.gohugo.io/t/how-to-use-groupbyparam-with-param-subkeys/48929/1 "2024-03-19T13:43:08Z")

</div>

I want to use the Pages.GroupByParam to group by a param subkey.

Example frontmatter taken from the [page.Params](https://gohugo.io/methods/page/params/) docs

```auto
{
   "date": "2023-10-17T15:11:37-07:00",
   "params": {
      "author": {
         "email": "jsmith@example.org",
         "name": "John Smith"
      },
      "display_related": true
   },
   "title": "Annual conference"
}

```

The param I am interested in is author.name and the following code works

```auto
{{ .Params.author.name }}

```

When I try to group pages by the author.name param the page errors out stating the param does not exist.

```auto
{{ range .Pages.GroupByParam "author.name" }}

```

Is there another way to do this?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 19, 2024, 1:58pm UTC](https://discourse.gohugo.io/t/how-to-use-groupbyparam-with-param-subkeys/48929/2 "2024-03-19T13:58:50Z")

</div>

```plaintext
{{ $p := slice }}
{{ $authors := slice }}
{{ range site.RegularPages }}
  {{ $p = $p | append (dict "author" .Params.author.name "page" .) }}
  {{ $authors = $authors | append .Params.author.name }}
{{ end }}
{{ $authors = $authors | uniq | sort }}

{{ range $authors }}
  <h2>{{ . }}</h2>
  {{ range where $p "author" . }}
    <h3><a href="{{ .page.RelPermalink }}">{{ .page.LinkTitle }}</a></h3>
  {{ end }}
{{ end }}

```

Please create a GitHub issue. Sorting works:

```auto
{{ range site.RegularPages.ByParam "author.name" }}

```

Grouping should work too:

```auto
{{ range site.RegularPages.GroupByParam "author.name" }}

```

* * *

See [https://github.com/gohugoio/hugo/issues/12289](https://github.com/gohugoio/hugo/issues/12289)
