Page.UniqueID is deprecated and will be removed in a future release. Use .File.UniqueID

I’m trying to use breadcrumb partial, but I keep getting this warning:

Page.UniqueID is deprecated and will be removed in a future release. Use .File.UniqueID

This is my breadcrumb code:

<ul class='uk-breadcrumb'>
    <li>
        <a href="/">Home</a>
    </li>
    <li>
        {{ template "breadcrumb" dict "currentPage" .Page "id" .UniqueID }}
    </li>
</ul>
    
{{ define "breadcrumb" }}
    {{ if .currentPage.Parent }}
        {{ if ne .currentPage.Parent .IsHome }}
        {{ template "breadcrumb" dict "currentPage" .currentPage.Parent }}
        {{ end }}
        {{ if eq .id .currentPage.UniqueID }}
            {{ .currentPage.Title }}
        {{ else }}
            <a href="{{ .currentPage.URL }}">{{ .currentPage.Title }}</a> >
        {{ end }}
    {{ end }}
{{ end }}

I tried to replace ‘.Page’ with ‘.File’ but when I do that I get an error. Is there any way to resolve it without getting warnings?

You don’t need to use UniqueID for this – just pass the page, and then do

{{ template "breadcrumb" dict "currentPage" "idPage" .Page  .}}
 {{ if eq .idPage .currentPage}}

Or something.

1 Like

Thank you @bep! Here’s the final code and it’s working now:

<ul class='uk-breadcrumb'>
    <li>
        <a href="/">Home</a>
    </li>
    <li>
        {{ template "breadcrumb" dict "currentPage" .Page }}
    </li>
</ul>
    
{{ define "breadcrumb" }}
    {{ if .currentPage.Parent }}
        {{ if ne .currentPage.Parent .IsHome }}
        {{ template "breadcrumb" dict "currentPage" .currentPage.Parent }}
        {{ end }}
        {{ if eq .id .idPage .currentPage }}
            {{ .currentPage.Title }}
        {{ else }}
            <a href="{{ .currentPage.URL }}">{{ .currentPage.Title }}</a> >
        {{ end }}
    {{ end }}
{{ end }}