Related posts in current Section

Hello. I used to try many variants and none work. Now I have this code:

{{ range first 4 ( sort (where (where .Site.RegularPages "Section" "blog") "URL" "!=" .URL) "Params.category" "desc") }}

But it is not correct, because I have the same result on all single pages.
I saw this manual https://gohugo.io/content-management/related/#readout, but I don’t understand how it works.

This code

{{ $related := .Site.RegularPages.Related . | first 5 }}

doesn’t have a Section tag.

What are you trying to output? Related content is configured separately, but your range looks like it should always show the same results. What are you trying to do?

I am trying to get different results. So, I saw the documentations again and didn’t understand, how can I configure related content. May be someone have example? (template example)

The examples worked for me when I tried them, so I’ll need to see what you tried before I can comment.

Yes, my example works. But I need an example which will be correct. I want to understand how can I show more relevant content for the post via a documentation.

Hello. Can someone give the example template or example code, how can create related posts?

			{{ with (where ($.Site.RegularPages.Related .Page) ".Params.layout" "=" "blog_single_tpl") | first 4 }}
				<div class="title">Related news</div>
				<ul class="list_grid">
					{{ range . }}
					<li>
						<a href="{{ .RelPermalink }}">
								<div class="preview_grid_title">{{ .Title }}</div>
						</a>
					</li>
					{{ end }}
				</ul>
			</div>
			{{ end }}

This is result.