Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Path when the page is backed by a file is deprecated and will be removed in a future release #369

Closed
kands-code opened this issue Jan 26, 2022 · 2 comments

Comments

@kands-code
Copy link
Contributor

Question Description

My hugo was installed through the system package manager, after updating to version 0.92, I encountered the following warning when executing hugo server -D

WARN 2022/01/26 11:46:45 .Path when the page is backed by a file is deprecated and will be removed in a future release.
We plan to use Path for a canonical source path and you probably want to check the source is a file.
To get the current behaviour, you can use a construct simlar to the below:

  {{ $path := "" }}
  {{ with .File }}
        {{ $path = .Path }}
  {{ else }}
        {{ $path = .Path }}
  {{ end }}


Re-run Hugo with the flag --panicOnWarning to get a better error message.

I think this is due to an update to hugo which has resulted in a change in the way the theme's templates are set up

System Info

System: Arch Linux
Package Manager: Pacman
Kernel: 5.16.2-zen1-1-zen
Hugo Version: hugo v0.92.0+extended linux/amd64 BuildDate=unknown
Go Version: go version go1.17.6 linux/amd64

relative link

@kands-code
Copy link
Contributor Author

I don't know how to write a Hugo theme, so I can't give any good advice, sorry

@kands-code
Copy link
Contributor Author

kands-code commented Jan 26, 2022

The error after adding the Flag --panicOnWarning is as follows:

$ hugo --panicOnWarning

Start building sites … 
hugo v0.92.0+extended linux/amd64 BuildDate=unknown
WARN 2022/01/26 12:10:56 .Path when the page is backed by a file is deprecated and will be removed in a future release.
We plan to use Path for a canonical source path and you probably want to check the source is a file.
To get the current behaviour, you can use a construct simlar to the below:

  {{ $path := "" }}
  {{ with .File }}
        {{ $path = .Path }}
  {{ else }}
        {{ $path = .Path }}
  {{ end }}
Error: Error building site:
  failed to render pages:
  render of "section" failed:
    execute of template failed:
      template: _default/list.html:3:7: executing "_default/list.html" at <partial "head.html" .>: error calling partial:
    execute of template failed:
      template: partials/head.html:26:15: executing "partials/head.html" at <partial "utils/title.html" (dict "$" . "title" .Title)>: error calling partial: "/home/kands/Documents/github-dir/kands-code.github.io/themes/meme/layouts/partials/utils/title.html:17:100":
    execute of template failed:
      template: partials/utils/title.html:17:100: executing "partials/utils/title.html" at <$.Path>: error calling Path: Warning trapped.
Remvove the --panicOnWarning flag to continue.
Total in 350 ms

did some line break

ulmefors pushed a commit to ulmefors/hugo-theme-meme that referenced this issue Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant