# Problem with condition

**URL:** <https://discourse.gohugo.io/t/problem-with-condition/22369>\
**Category:** support\
**Created:** [December 17, 2019, 10:14am UTC](https://discourse.gohugo.io/t/problem-with-condition/22369 "2019-12-17T10:14:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![igramnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/igramnet/32/2715_2.png) [@igramnet](https://discourse.gohugo.io/u/igramnet)\
**Post date:** [December 17, 2019, 10:14am UTC](https://discourse.gohugo.io/t/problem-with-condition/22369/1 "2019-12-17T10:14:18Z")

</div>

Hello. I have a code in my template

```
{{ .Scratch.Set "hosting_type" "dedicated" }}
{{ $hosting_type := .Scratch.Get "hosting_type" }}
{{ $url_type = printf "%s/" $hosting_type }}
{{ $url_windows_en := delimit (slice "/hosting/" $url_type "windows/") "" }}
<br>
<b>{{ .RelPermalink }}</b>
<br>
<b>{{ $url_windows_en }}</b>
<br>
{{ if or (eq .URL $url_windows_en) }}
test code
{{ end }}

```

But on a page I see a result:

```
<br>
<b>/hosting/dedicated/windows/</b>
<br>
<b>/hosting/dedicated/windows/</b>
<br>

```

Why I don’t see the phrase “test code”?

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [December 17, 2019, 12:44pm UTC](https://discourse.gohugo.io/t/problem-with-condition/22369/2 "2019-12-17T12:44:40Z")

</div>

To start, your if/or statement is missing a 2nd arg.

---

<div class="post-metadata">

**Author:** ![igramnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/igramnet/32/2715_2.png) [@igramnet](https://discourse.gohugo.io/u/igramnet)\
**Post date:** [December 17, 2019, 12:50pm UTC](https://discourse.gohugo.io/t/problem-with-condition/22369/3 "2019-12-17T12:50:24Z")

</div>

@zwbetz, which argument I lost?

{{ if or (eq .URL $url\_windows\_en) }} is as {{ if eq .URL $url\_windows\_en }}, right?  
One arg - .URL  
Two arg - $url\_windows\_en

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [December 17, 2019, 2:07pm UTC](https://discourse.gohugo.io/t/problem-with-condition/22369/4 "2019-12-17T14:07:33Z")

</div>

> [@igramnet](#):
>
> Why I don’t see the phrase “test code”?

If you don’t see `test code` it means your `if` statement evaluates to `false`.

`or` is missing a second arg:

```auto
{{ if or (eq .URL $url_windows_en) }}
         '------ or arg 1 -------' '-- or arg 2 missing --'

```

What is the value of `.URL`? (Page `.URL` is being deprecated, by the way)

To help you debug, print `{{ eq .URL $url_windows_en }}`. It is probably `false`.

---

<div class="post-metadata">

**Author:** ![igramnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/igramnet/32/2715_2.png) [@igramnet](https://discourse.gohugo.io/u/igramnet)\
**Post date:** [December 18, 2019, 8:03am UTC](https://discourse.gohugo.io/t/problem-with-condition/22369/5 "2019-12-18T08:03:58Z")

</div>

> [@pointyfar](#):
>
> {{ eq .URL $url\_windows\_en }}

It doesn’t matter.  
Okay, I add this code

```
{{ .Scratch.Set "mytype" "" }}
{{ $mytype := .Scratch.Get "mytype" }}
{{ $myurl := "" }}
{{ if ne $hosting_type ""}}
{{ $myurl = printf "%s/" $mytype }}
{{ end }}
{{ $url_windows := delimit (slice "/hosting/" $myurl "windows/") "" }}
<b>{{ .RelPermalink }}</b><br>
<b>{{ $url_windows }}</b><br>
{{ eq .RelPermalink $url_windows }}

```

And the result is

```
<b>/hosting/windows/</b><br>
<b>/hosting/windows/</b><br>
false

```

Why? I think something problem with this code

`{{ $url_windows := delimit (slice "/hosting/" $myurl "windows/") "" }}`

Maybe type does not string?

---

<div class="post-metadata">

**Author:** ![igramnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/igramnet/32/2715_2.png) [@igramnet](https://discourse.gohugo.io/u/igramnet)\
**Post date:** [December 18, 2019, 8:06am UTC](https://discourse.gohugo.io/t/problem-with-condition/22369/6 "2019-12-18T08:06:58Z")

</div>

Solution:

```
{{ .Scratch.Set "mytype" "" }}
{{ $mytype := .Scratch.Get "mytype" }}
{{ $myurl := "" }}
{{ if ne $hosting_type ""}}
{{ $myurl = printf "%s/" $mytype }}
{{ end }}
{{ $url_windows := delimit (slice "/hosting/" $myurl "windows/") "" }}
<b>{{ .RelPermalink }}</b><br>
<b>{{ $url_windows }}</b><br>
{{ eq .RelPermalink (string $url_windows) }}
```
