{{ with $tag := .Get 0 }}
{{ with site.RegularPages.RelatedTo (keyVals "tags" $tag) }}
{{ with where . "Permalink" "ne" $.Page.Permalink }}
<p>Related pages:
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
</p>
{{ end }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a single positional parameter. See %s" .Name .Position }}
{{ end }}
Option 2 - Where plus intersect
{{ with $tag := .Get 0 }}
{{ with where site.RegularPages "Params.tags" "intersect" (slice $tag) }}
{{ with where . "Permalink" "ne" $.Page.Permalink }}
<p>Related pages:
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
</p>
{{ end }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a single positional parameter. See %s" .Name .Position }}
{{ end }}
I made a minor change to each of the approaches in my previous post to prevent rendering “Related pages” if the current page is the only page with the given tag.