Problem
When building my website, I get this warning:
~/code/tshark.dev $ hugo serve
Building sites … WARN 2020/03/30 18:06:07 Page.Dir is deprecated and will be removed in a future release. Use .File.Dir
Repos
For this question, the (tagged) relevant repos are
- My tshark.dev repo,
github.com/pocc/tshark.dev
, on commit e8efe14 - The hugo learn theme, which at question time, is on commit b5c759a
Version info
$ hugo version
Hugo Static Site Generator v0.65.3/extended darwin/amd64 BuildDate: unknown
Description
A similar question about .File.Dir is here (not linked with markdown due to new user): [Error: What to replace .File.Dir with in hugo-book](https://discourse.gohugo.io/t/error-what-to-replace-file-dir-with-in-hugo-book/18118)
.
Using the bash provided by @bep in that post:
$ findDir () { find . -name "*.html" | xargs grep "\.Dir"; }
$ findDir
./layouts/shortcodes/attachments.html: {{ range (readDir (printf "./content/%s%s" .Page.File.Dir ($.Scratch.Get "filesName")) ) }}
./layouts/shortcodes/attachments.html: {{ $fileDir := replace $.Page.File.Dir "\\" "/" }}
./layouts/partials/header.html: <a class="github-link" title='{{T "Edit-this-page"}}' href="{{ $Site.Params.editURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}" target="blank">
But these .Dir
usages are the exact same as the ones in the theme, and the theme does not have this issue. To demonstrate (with both repos downloaded to a ~/code
folder:
$ diff <(cd ~/code/tshark.dev; findDir) <(cd ~/code/hugo-theme-learn/; findDir)
Question
Which file is causing this warning and how can I fix it?