{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
{{ $.Scratch.Set "has_related" true }}
{{ end }}

{{ if $.Scratch.Get "has_related" }}

    {{ $num_to_show := .Site.Params.related_content_limit | default 7 }}
    <ul id="related-tools">
        {{ range first $num_to_show (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
        <li>
            <a href="{{ .RelPermalink }}">
                