# Show different related posts in one section only

**URL:** <https://discourse.gohugo.io/t/show-different-related-posts-in-one-section-only/35904>\
**Category:** support\
**Created:** [December 5, 2021, 11:45am UTC](https://discourse.gohugo.io/t/show-different-related-posts-in-one-section-only/35904 "2021-12-05T11:45:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![esawertu](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@esawertu](https://discourse.gohugo.io/u/esawertu)\
**Post date:** [December 5, 2021, 11:45am UTC](https://discourse.gohugo.io/t/show-different-related-posts-in-one-section-only/35904/1 "2021-12-05T11:45:10Z")

</div>

I am using the code below to show related posts. How can I wrap it in an `if else` statement so I show different related posts for one section called `views`?

```auto
  {{ $filteredPosts := ( where (site.RegularPages.Related .) "Type" "post") }}  
    {{ $relatedPosts := shuffle $filteredPosts | first 6 }}  
    {{ range $relatedPosts }}  
      <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
      {{ end }}

```

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [December 5, 2021, 4:16pm UTC](https://discourse.gohugo.io/t/show-different-related-posts-in-one-section-only/35904/2 "2021-12-05T16:16:42Z")

</div>

```auto
{{ if eq .Section "views" }}

```

I’m not sure I understand correctly but the condition you’re looking for is a test on `.Section` ( a string)

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [December 7, 2021, 5:21pm UTC](https://discourse.gohugo.io/t/show-different-related-posts-in-one-section-only/35904/4 "2021-12-07T17:21:58Z")

</div>

Closed on December 7, 2021, 5:21pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
