# .Path when the page is backed by a file is deprecated

**URL:** <https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842>\
**Category:** support\
**Created:** [January 29, 2022, 10:22am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842 "2022-01-29T10:22:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)\
**Post date:** [January 29, 2022, 10:22am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/1 "2022-01-29T10:22:38Z")

</div>

Hi there, I really don’t understand this error message. Do I need to update my layout?

```auto
(ins)[hendry@t14s dabase.com]$ rg Path layouts/
layouts/partials/footer.html
3:{{ $editURL := printf "%s/edit/master/content/%s" "https://github.com/kaihendry/dabase.com" .Path }}
4:{{ $commitsURL := printf "%s/commits/master/content/%s" "https://github.com/kaihendry/dabase.com" .Path }}
(ins)[hendry@t14s dabase.com]$ hugo --panicOnWarning
Start building sites …
hugo v0.92.0+extended linux/amd64 BuildDate=unknown
WARN 2022/01/29 18:20:42 .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 }}

^C
(ins)[hendry@t14s dabase.com]$ hugo version
hugo v0.92.0+extended linux/amd64 BuildDate=unknown

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [January 30, 2022, 1:25pm UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/2 "2022-01-30T13:25:17Z")

</div>

🙄

Could you please explain, how to make the message more obvious? We sometimes have issues having self-explanatory error messages, but to me, this looks quite such (self-explanatory):

- Look for the `.Path` variable.
- Replace with the code that is offered as a replacement.
- Be happy it works again.

You have somewhere in your layout a range that goes over the page content and `thepageyouareworkingwith.Path` stopped existing. Because it is the same as `.File.Path` which that code sample would add or fall back gracefully if you are somewhere completely else.

If that still does not help you, please post the whole layout that throws the warning. But you will see that the end result is exactly the same 😉 Someone will replace your `.Path` with `.File.Path`.

And as I wrote above, if that error message is really so hard to understand for a non-developer (sorry if I sorted you into the wrong `house` here) please let us know how to do it better.

---

<div class="post-metadata">

**Author:** ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)\
**Post date:** [January 31, 2022, 4:53am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/3 "2022-01-31T04:53:09Z")

</div>

The message doesn’t indicate which layout file needs updating.

`panicOnWarning` doesn’t offer a better error message.

Tbh I am quite confused how to update [dabase.com/footer.html at master · kaihendry/dabase.com · GitHub](https://github.com/kaihendry/dabase.com/blob/master/layouts/partials/footer.html) … the code replacement doesn’t quite make sense to me.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 31, 2022, 5:29am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/4 "2022-01-31T05:29:52Z")

</div>

> [@hendry](#):
>
> `panicOnWarning` doesn’t offer a better error message.

Yes, it does.

> Error: Error building site: failed to render pages: render of “page” failed: execute of template failed: template: \_default/single.html:12:3: executing “\_default/single.html” at \<partial “footer” .\>: error calling partial: “/home/jmooring/code/hugo-testing/layouts/partials/footer.html:3:96”

It’s telling you that the there’s a problem on line 3, column 96 of footer.html

> [@hendry](#):
>
> I am quite confused how to update

As the warning suggests, wrap using `with .File`

```auto
<footer>
  <p>Comments? <a href="mailto:hendry+dabase@iki.fi?subject={{ .Title }}">Email Kai Hendry please</a> or <a href="https://twitter.com/kaihendry/">@kaihendry on Twitter</a></p>
  {{ with .File }}
    {{ $editURL := printf "%s/edit/master/content/%s" "https://github.com/kaihendry/dabase.com" .Path }}
    {{ $commitsURL := printf "%s/commits/master/content/%s" "https://github.com/kaihendry/dabase.com" .Path }}
    <a href="{{ $editURL }}">Edit this</a>
    |
    <a href="{{ $commitsURL }}">File history</a>
  {{ end }}
  <small>Last Build time: {{ now.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</small>
</footer>

```

Your site should have been structured this way from the beginning, because it doesn’t make sense to offer edits to pages that are not backed by files. For example, going to [https://dabase.com/tags/](https://dabase.com/tags/) and pressing the edit link _currently_ throws a 404 error.

---

<div class="post-metadata">

**Author:** ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)\
**Post date:** [January 31, 2022, 6:32am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/5 "2022-01-31T06:32:09Z")

</div>

> [@hendry](#):
>
> panicOnWarning

When I run `hugo --panicOnWarning` (see initial post), I don’t get that error, unless I am missing something?

Thank you very much! [Many thanks Mr Mooring https://discourse.gohugo.io/t/path-when-the-pa… · kaihendry/dabase.com@f5cd6a5 · GitHub](https://github.com/kaihendry/dabase.com/commit/f5cd6a5d807bb03e2496bd3b2041740c11a5e46d)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 31, 2022, 6:49am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/6 "2022-01-31T06:49:08Z")

</div>

> [@hendry](#):
>
> I don’t get that error,

I don’t know what to tell you. With v0.92.1

```bash
hugo --panicOnWarning 

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/9/4/941df04240f29c95f60f2f2793cdc69ab033b82f.png)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 31, 2022, 6:57am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/7 "2022-01-31T06:57:46Z")

</div>

And when I build _your_ site (before you made the corrections to footer.html)…

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/a/6/a634752f43318dffc3e4a881ccbcabfff1e3ebde.png)

…the information is there

> execute of template failed: template: partials/footer.html:10:44

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [February 2, 2022, 6:58am UTC](https://discourse.gohugo.io/t/path-when-the-page-is-backed-by-a-file-is-deprecated/36842/8 "2022-02-02T06:58:31Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
