.URL Warning and .Permalink Error

Hi wonderful peoples. There was probably a better title for this, but I am not sure what it is. Hopefully my ignorance here will help others.

So I am getting the “.URL is deprecated…use .Permalink” message. So I try to fix it by replacing .URL with .Permalink or .RelPermalink, but then I get “can’t evaluate field Permalink” error.

My hunch is that this is a scoping issue? Can anyone suggest a change to my code below that would resolve this issue?

Thanks in advance,

Jeff

{{ define "menu-node" }}
  {{ if .HasChildren }}
    <li class="nav-item">
        <a class="nav-link has-sub-menu" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
        <ul class="sub-menu">
          {{ range .Children.ByWeight }}
            {{ template "menu-node" . }}
          {{ end }}
        </ul>
    </li>
  {{else}}
  <li class="nav-item">
    <a class="nav-link" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
  </li>
  {{ end }}
{{ end }}
 
<nav class="nav docs-nav">
  <ul class="nav-list">
    {{ range .Site.Menus.docs }}
      {{ template "menu-node" . }}
    {{end}}
  </ul>
</nav>


{{ .URL }} is still appropriate when working with menus. My hunch is that there’s somewhere else in your site that’s causing this.

1 Like

Hey Zack,

That is great news. Yeah, I am sure there are some other instances of .URL. Nice to know this does not apply to menus.

Thanks for the quick reply,

Jeff