[Solved] Help using range

Hugo and golang newbie here and I hit a roadblock with range.

I’m trying to setup authors for a blog so I have set up data/authors folder and I have a toml file for each author.

I’n my template I’m doing this:

{{ if isset .Params "author" }}
        {{ range $index, .Site.Data.authors }}
            {{ if eq .Params.author $index.author }}
                <img src="{{ .thumbnail }}" alt="{{ .name }}">
                <p>{{ .name }}</p>
                <p>{{ .bio }}</p>
                <a href="{{ .linkedin }}"></a> 
                <a href="{{ .twitter }}"></a>
            {{ end }}
        {{ end }}
    {{ end }}

Now this is what I don’t understand instead of displaying the author that matches the frontMatter author it’s removing it and rendering the other authors.

I know there might be an easier way to do it with range I just don’t know how yet.

Thanks.

After fiddling around with this some more I figured it out.

I changed my code to this:

{{ if isset .Params "author" }}
        {{ range $index, .Site.Data.authors }}
            {{ if eq $.Params.author $index.author }}
                <img src="{{ .thumbnail }}" alt="{{ .name }}">
                <p>{{ .name }}</p>
                <p>{{ .bio }}</p>
                <a href="{{ .linkedin }}"></a> 
                <a href="{{ .twitter }}"></a>
            {{ end }}
        {{ end }}
    {{ end }}

Now it works how it should.

Thanks. I had a similar problem.