# If statement and html

**URL:** <https://discourse.gohugo.io/t/if-statement-and-html/36449>\
**Category:** support\
**Created:** [January 8, 2022, 5:11pm UTC](https://discourse.gohugo.io/t/if-statement-and-html/36449 "2022-01-08T17:11:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steph1](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Steph1](https://discourse.gohugo.io/u/Steph1)\
**Post date:** [January 8, 2022, 5:11pm UTC](https://discourse.gohugo.io/t/if-statement-and-html/36449/1 "2022-01-08T17:11:09Z")

</div>

Hi all,

I have been migrating from Jekyll to Hugo (and I’m doing pretty good so far!). But I have a small problem. I have been using this code on my template but I can’t find a way to translate it in Go.

I know the conditional statements have a different syntax with Go and I’ve been reading about that, but I can’t find the solution.

Thanks a lot for your help  
Steph

```auto
 <li {% if page.url == "/index.html" %}class="active"{% endif %}>
                    <a href="index.html">HOME</a>
                </li>

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 8, 2022, 6:10pm UTC](https://discourse.gohugo.io/t/if-statement-and-html/36449/2 "2022-01-08T18:10:23Z")

</div>

A basic comparison construct…

```auto
{{ if eq $var1 $var2 }}
  ...
{{ end }}

```

The same, but inline…

```auto
{{ if eq $var1 $var2 }}...{{ end }}

```

If you are ranging through pages and want to handle the home page differently…

```auto
{{ range .Site.Pages }}
  <li {{ if .IsHome }}class="active"{{ end }}>
    <a href="{{ .RelPermalink }}">{{ .Title }}</a>
  </li>
{{ end }}

```

Based on lack of context, what you are trying to accomplish is unclear.

---

<div class="post-metadata">

**Author:** ![Steph1](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Steph1](https://discourse.gohugo.io/u/Steph1)\
**Post date:** [January 8, 2022, 7:42pm UTC](https://discourse.gohugo.io/t/if-statement-and-html/36449/3 "2022-01-08T19:42:01Z")

</div>

Thank you. This is exactly what I needed. 😀

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [January 10, 2022, 7:42pm UTC](https://discourse.gohugo.io/t/if-statement-and-html/36449/4 "2022-01-10T19:42:15Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
