0.65.0 change to behavior of ref shortcode


I have a directory layout like this:


In 0.64.1, it was possible to link from the source.md file to target using {{< ref “target.md” >}}. As of 0.65.0, that no longer works, and I need to provide the absolute path to target.md to ref in order to get a link.

Is this change intended, and is it correctly understood that ref now only checks the current directory and parent directories for relative paths, and not the entire directory structure?

I have checked the latest release (0.85.0) and this change seems to also apply to that version.

I think this issue might be related, but it appears to have fixed some of the cases of this, but apparently not all.

I am unable to reproduce the problem with v0.85.0. Try:

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

Then visit http://localhost:1313/section1/subsection/source/

1 Like

Hi Joe,

Thank you for looking into this, and for providing an example project.

I was able to reproduce this with a slight adjustment to your example.

It appears that 0.64.1 resolves {{< ref "target.md" >}} to only the target.md file, while 0.85.0 will be confused by the presence of both a target.md file, as well as a target/_index.md.

Not sure if related but have a look at https://github.com/gohugoio/hugo/issues/6952

Thanks, but I already looked at that issue, it was the one I linked to in the OP :slight_smile:

Those are logically the same “thing”. You may argue that this has changed since 0.65 (which is a pretty old Hugo version), but the use of short references kind of only works if you have either a very small site or use very distinctive filenames.

Note that we now support page-relative refs, which should make them more robust , e.g. {{< ref "../foo/target.md" >}}

Okay, that makes sense. I’ll update our references to disambiguate these cases. It definitely has changed since 0.64.1, but as long as it is intentional, that’s not necessarily a bad thing.

Thanks for explaining.

1 Like

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