gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.38k stars 7.49k forks source link

Handle file names with multiple dots when getting a page #10864

Closed jmooring closed 8 months ago

jmooring commented 1 year ago

Overview

The functions and methods below cannot resolve a path to a page if (a) the filename (including the extension) contains multiple dots, and (b) the path argument passed to the function or method does not include the file extension.

Examples

Path arg does not have file extension

Template code Result
{{ .Page.GetPage "news/2021/0.91.2-relnotes" }} error REF_NOT_FOUND
{{ .Site.GetPage "news/2021/0.91.2-relnotes" }} error REF_NOT_FOUND
{{ .Page.Ref (dict "path" "news/2021/0.91.2-relnotes") }} error REF_NOT_FOUND
{{ .Page.RelRef (dict "path" "news/2021/0.91.2-relnotes") }} error REF_NOT_FOUND
{{ ref . "news/2021/0.91.2-relnotes" }} error REF_NOT_FOUND
{{ relref . "news/2021/0.91.2-relnotes" }} error REF_NOT_FOUND

Path arg has file extension

Template code Result
{{ .Page.GetPage "news/2021/0.91.2-relnotes.md" }} OK
{{ .Site.GetPage "news/2021/0.91.2-relnotes.md" }} OK
{{ .Page.Ref (dict "path" "news/2021/0.91.2-relnotes.md") }} OK
{{ .Page.RelRef (dict "path" "news/2021/0.91.2-relnotes.md") }} OK
{{ ref . "news/2021/0.91.2-relnotes.md" }} OK
{{ relref . "news/2021/0.91.2-relnotes.md" }} OK

Motivation

If, on an existing site, you implement a link render hook that resolves link destinations (no extension) to pages, the render hook will not be able to find the page, limiting your ability to create portable links. Again, this only applies to filenames with multiple dots.

The path used in the examples above is from the Hugo docs site.

This enhancement would also resolve https://github.com/gohugoio/hugo/issues/9918.

jmooring commented 8 months ago

This was resolved with https://github.com/gohugoio/hugo/pull/11894

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.