`ref` not working when using relative path since v0.123.0

Hi, I noticed that the ref is not working with relative paths since v0.123.0, I’m not sure if this is by designed or should be considered as a bug.

[link]({{< ref "../../k8s-on-raspi" >}})

I assume something like this:

content/
β”œβ”€β”€ s1/
β”‚   β”œβ”€β”€ s2/
β”‚   β”‚   β”œβ”€β”€ s3/
β”‚   β”‚   β”‚   β”œβ”€β”€ _index.md
β”‚   β”‚   β”‚   └── p1.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ _index.md
β”‚   └── k8s-on-raspi.md  <-- you want to get here from s1/s2/s3/p1.md
└── _index.md

Is that correct? If so, it’s working for me:

git clone --single-branch -b hugo-forum-topic-48939 https://github.com/jmooring/hugo-testing hugo-forum-topic-48939
cd hugo-forum-topic-48939
hugo server

hugo v0.124.1-db083b05


Since v0.123.0, the functions and methods that resolve pages (including the ref and relref shortcodes) look for the logical path. See https://gohugo.io/methods/page/path/.

1 Like

Thanks for spending time on this, I modified the structure for reproducing the issue, seems related to page bundle.

Your screen shot shows

[link]({{< ref "../../../k8s-on-raspi" >}})

But you originally reported

[link]({{< ref "../../k8s-on-raspi" >}})

Which is it?

[link]({{< ref "../../../k8s-on-raspi" >}})

I’m sorry I didn’t make myself clear, the above is the right one for this branch. The original one was copied from different structures (depth 2).

Please see my initial response… use the logical path as described in the docs.

content/
β”œβ”€β”€ s1/                    --> k8s-on-raspi.md brings you to your destination
β”‚   β”œβ”€β”€ s2/                --> ../ brings you to s1
β”‚   β”‚   β”œβ”€β”€ s3/
β”‚   β”‚   β”‚   β”œβ”€β”€ _index.md 
β”‚   β”‚   β”‚   └── p1.md      --> ../ brings you to s2
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ _index.md
β”‚   └── k8s-on-raspi.md
└── _index.md

The original structure is OK, what about the following structure.

content
β”œβ”€β”€ _index.md  
└── s1
    β”œβ”€β”€ _index.md
    β”œβ”€β”€ k8s-on-raspi
    β”‚   └── index.md
    └── s2                              --> ../ to s1
        β”œβ”€β”€ _index.md
        └── s3                          --> ../ to s2
            β”œβ”€β”€ _index.md
            └── p1                      --> ../ to s3
                └── index.md

And I modified the path as follows.

// content/s1/s2/s3/p1/index.md
[link]({{< ref "../../../k8s-on-raspi" >}})

No. The LOGICAL path is different from the file path. See the documentation!

https://gohugo.io/methods/page/path/#logical-tree

image

1 Like

Thanks.

Just as file paths form a file tree, logical paths form a logical tree.

That’s the first sentence. And what a β€œlogical path” is, is never clearly defined. This sentence is kind of circular, referring to another concept. It should explain the new one. Something like
β€œA logical path considers directories/folders and content files in the same immediate parent directory/folder as path components on the same level.” Or whatever correctly describes the concept (since I don’t quite understand it, I can’t proposed a good definition).

1 Like

Maybe this one ma help

1 Like

Kind of. But I stll think that the definition of a concept should appear (also) at the place where the concept is introduced (and the example the glossary of the term refers to does not illustrate all the facets, like spaces being replaced by dashes and lowercasing the names).

The right word to use in these definitions would be β€œnode”, showing a β€œnode tree” example, then describing the logical path as the path between two nodes, either relative to each other or absolute from the root of the tree.

Every time I’ve encountered a concept like this it is called a β€œnode”.

Unfortunately, a very long time ago, Hugo limited the definition of node to page kinds home, section, taxonomy, term, 404, and maybe some others, but the definition excludes page kind page.

https://gohugo.io/methods/page/isnode/

I’ve wanted to deprecate this for a long time because the definition doesn’t make any sense.
https://github.com/gohugoio/hugo/issues/11574

Also see:
https://github.com/gohugoio/hugoDocs/issues/2500

3 Likes

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