Exclude current page from the related pages when using .RegularPages.Related

Hi there,

I am using the .RegularPages.Related to list all the pages in content/vegetables/

It list everything including the current page I am on, I cannot find a way to exclude the current page from the list

Any ideas on how to use {{ $related := .RegularPages.Related . }} while not listing the current page you are on

for example I have list of pages at: example.com/vegetables/

  • Apple
  • Banana
  • Peach

when I click a page and visit example.com/vegetables/apple/ I see list of related pages

  • Apple
  • Banana
  • Peach

Since I am already on the page example.com/vegetables/apple/ how can I exclude that from the list of related pages shown

Thanks for taking the time

On my end, whenever I used related pages, I never saw the current page listed,however you can try excluding it with something like:

{{ range where (site.RegularPages.Related .) "Permalink" "ne" .Permalink }}
  ...
{{ end }}

In the above if the Permalink value equals the current pager’s .Permalink then it will not be listed.

1 Like

thanks @alexandros

this did the job I can now only see the related pages without the current page I am on thanks :pray:

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