HUGO

[SOLVED] Check if current page is present in a menu

I would like to know how I can check if the current page is present in a specific menu.

Played around with in function, but without any luck.

  {{ if in .Site.Menus.company .Title }}This page is in the menu{{ end }}

Don’t know if this is the best option, but gets the job done

{{ $current := print "/" (index (split .URL "/") 1) "/" }}
{{ $menu := .Site.Menus.company }}
{{ range $menu }}
   {{ if eq .URL $current }}
         <div class="bg-grey-lightest rounded-lg pt-8 pb-4 px-4 md:px-8 ">
              <h5 class="text-2xl medium mb-4 xl:mb-6">
                Menu Title
              </h5>
              {{- $firstUrlElement := print "/" (index (split .URL "/") 1) "/" -}}
              {{- range $menu -}}
                <a class="block leading-tight text-purple mb-4 xl:mb-4 hover:text-purple  {{if eq ($firstUrlElement|lower) (.URL|lower) }}active{{end}}" href="{{ .URL }}" title="{{ .Name }} page">
                  {{ .Name }}
                </a>
                {{ end }}
         </div>
   {{ end }}
{{ end }}

Does .HasMenuCurrent / .IsMenuCurrent not work for you?