Custom Menu and active class

I’m struggling to understand how to give class ‘active’ with a custom menu.
I have a partial called _render_nav.html where i have my menu template

{{ $currentPage := . }}
{{ range .menu.navigation }}
  {{ if .HasChildren }}
    <li class='dropdown'>
      <a class='arrow'>{{ .Name }}</a>
      <ul class='submenu'>
        {{ range .Children }}
          <li class="{{ if $currentPage.HasMenuCurrent ".menu.navigation" . }}active{{ end }}">
            <a href='{{ .URL }}'>{{ .Name }}</a>
        {{ end }}
  {{ else }}
      <a href='{{ .URL }}'>{{ .Name }}</a>
  {{ end }}
{{ end }}

And then under > data > nav.yml i have my menus

    - Name: "Learn"
      URL: "/learn"
    - Name: "Contribute"
      URL: "/contribute"
    - Name: "Community"
      URL: "/community"
      HasChildren: true
        - Name: "Chapters"
          URL: "/chapters"
        - Name: "Projects"
          URL: "/projects"
        - Name: "Our Stories"
          URL: "/stories"
    - Name: "About"
      URL: "/about"
        - Name: "Our history"
          URL: "/history"
        - Name: "Projects"
          URL: "/projects"
        - Name: "Where"
          URL: "/where/"
        - Name: "What drive us"
          URL: "/drive"
        - Name: "Contact"
          URL: "/contact"
    - Name: "Twitter"
      icon: "twitter"
      URL: ""
    - Name: "Facebook"
      icon: "facebook"
      URL: ""
    - Name: "Donate"
      icon: "heart"
      URL: "/foundation/donate"

Server watch complain that the key menu.navigation is illegal :confused:
Can someone help me to understand how the look up for menus works?
I have nothing defined in my config file

The way you try to use your menu with the {{ if $currentPage.HasMenuCurrent ".menu.navigation" . }} code is from what I understand meant for when your menu is specified in the configuration file. If you use a data file for your menu I don’t think you can use HasMenuCurrent.

It’s probably easier to set your menu in the configuration file, instead of the nav.yml data file.

See Hugo menus and using menus in Hugo template code for a bit more information about how menus work.