A better way to write this conditional logic [solved]

Hey guys I need help writing this a bit more cleaner it works exactly as I want it but I am sure there is a better way. Thanks

{{ if in .RelPermalink "/blog" }}
{{else if in .RelPermalink "/release-notes"}}
    <a href="{{.Permalink}}">{{.Title}}</a>

I don’t know, that kind of looks good to me.

I guess if you really wanted to check the docs and see if you can put those into an array or something?
Then only print the permalink if it’s not in the array - that way you don’t have to add a conditional statement for each of those strings you’re referencing (should you decide to add/remove more of them).

ETA: If an array isn’t available maybe use an “excluded_pages” data file.
That’ll allow you to include a brief description as to why you’re excluding the page(s) for future reference or something.

I would like to use an or condition on the first if statement that way I can get rid of the else if, I just don’t know how to do it :confused:

Thanks for replying :slightly_smiling_face:

Here’s describes how to “or”: https://gohugo.io/templates/introduction/#example-1-if

Yes - as @Leo_Merkel stated: the doc for conditions is under https://gohugo.io/templates/introduction/#logic - read through the hole page…

your 1:1 “translated” example would look something like:

{{- if not (or (in .RelPermalink "/blog") (in .RelPermalink "/release-notes") ) }}
      <a href="{{.Permalink}}">{{.Title}}</a>
{{- end}}

There is the missing piece the not, I was just using the or and was going nowhere but error land, thanks guys.

If you wouldn’t mind can you post what this logic would look like using a pipe? Also tried many things to no avail, thanks again.