Conditionals with this style [[params.user_defined]]


I’m trying to output params wrapped by p tag or a tag by whether they have links in their values.
Here are my config.toml.

    name = "Address"
    url = false
    name = "GitHub"
    url = ""

And my code is this.

<ul class="footer-contents">
    {{ range .Site.Params.footer }}
        {{ if ne .Params.footer.url false }}
            <li class="footer-contents__item"><a href="{{ .url }}">{{ .name }}</a></li>
        {{ else }}
            <li><p class="footer-contents__item">{{ .name }}</p></li>
        {{ end }}
    {{ end }}

I expeced that first Address should be rendered as p and second be a. But Hugo rendered both as a.
Is there any mistake for my logic or do I take wrong way at all?

Thank you,

Your if block is inside the range context :

Inside of an iteration, however, it will have the value of the current item in the loop; i.e., {{ . }} will no longer refer to the data available to the entire page.


{{ range .Site.Params.footer }}
  {{ if ne .url false }}

It completely works! Thanks a lot for replying such beginner’s question! :bowing_man: