shithub: hugo

Download patch

ref: 59c4bc52ed6b146baa6cca97d054004297ea098a
parent: dc1d4a9200c54e631775f34725140fd5009aa561
author: Justin Van Patten <[email protected]>
date: Tue Jun 25 19:26:02 EDT 2019

Include path to source page in non-relative ref/relref warning

We occasionally see warnings when building our site:

```
WARN 2019/06/25 23:07:08 make non-relative ref/relref page reference(s) in page %q absolute, e.g. {{< ref "/blog/my-post.md" >}}
```

But the `%q` value is missing, making it difficult to track down the source of the warning.

This change addresses that, by including the source path in the warning:

```
WARN 2019/06/25 23:07:31 make non-relative ref/relref page reference(s) in page "blog/my-post/index.md" absolute, e.g. {{< ref "/blog/my-post.md" >}}
```

--- a/hugolib/pagecollections.go
+++ b/hugolib/pagecollections.go
@@ -283,7 +283,7 @@
 		if err == nil && p != nil {
 			if context != nil {
 				// TODO(bep) remove this case and the message below when the storm has passed
-				err := wrapErr(errors.New(`make non-relative ref/relref page reference(s) in page %q absolute, e.g. {{< ref "/blog/my-post.md" >}}`), context)
+				err := wrapErr(errors.Errorf(`make non-relative ref/relref page reference(s) in page %q absolute, e.g. {{< ref "/blog/my-post.md" >}}`, context.Path()), context)
 				helpers.DistinctWarnLog.Println(err)
 			}
 			return p, nil