-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to support unix-style path semantics #4728
Comments
This was referenced May 30, 2018
bep
pushed a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit unifies the core internal page index for all page kinds. This enables the `ref` and `relref` shortcodes to support all pages kinds, and adds a new page-relative `.GetPage` method with simplified signature. Fixes gohugoio#4147 Fixes gohugoio#4727 Fixes gohugoio#4728 Fixes gohugoio#4728 Fixes gohugoio#4726 Fixes gohugoio#4652
bep
pushed a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit unifies the core internal page index for all page kinds. This enables the `ref` and `relref` shortcodes to support all pages kinds, and adds a new page-relative `.GetPage` method with simplified signature. Fixes gohugoio#4147 Fixes gohugoio#4727 Fixes gohugoio#4728 Fixes gohugoio#4728 Fixes gohugoio#4726 Fixes gohugoio#4652
bep
pushed a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit unifies the core internal page index for all page kinds. This enables the `ref` and `relref` shortcodes to support all pages kinds, and adds a new page-relative `.GetPage` method with simplified signature. See gohugoio#4147 See gohugoio#4727 See gohugoio#4728 See gohugoio#4728 See gohugoio#4726 See gohugoio#4652
bep
added a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit is a follow up to a recent overhaul of the GetPage/ref/relref implemenation. The most important change in this commit is the update to `.Site.GetPage`: * To reduce the amount of breakage in the wild to its minimum, I have reworked .Site.GetPage with some rules: * We cannot support more than 2 arguments, i.e. .Site.GetPage "page" "posts" "mypage.md" will now throw an error. I think this is the most uncommon syntax and should be OK. It is an easy fix to change the above to .Site.GetPage "/posts/mypage.md" or similar. * .Site.GetPage "home", .Site.GetPage "home" "" and .Site.GetPage "home" "/" will give you the home page. This means that if you have page in root with the name home.md you need to do .Site.GetPage "/home.md" or similar This commit also fixes some multilingual issues, most notable it is now possible to do cross-language ref/relref lookups by prepending the language code to the path, e.g. `/jp/posts/mypage.md`. This commit also reverts the site building tests related to this to "Hugo 0.44 state", to get better control of the changes made. Closes gohugoio#4147 Closes gohugoio#4727 Closes gohugoio#4728 Closes gohugoio#4728 Closes gohugoio#4726 Closes gohugoio#4652
bep
added a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit is a follow up to a recent overhaul of the GetPage/ref/relref implemenation. The most important change in this commit is the update to `.Site.GetPage`: * To reduce the amount of breakage in the wild to its minimum, I have reworked .Site.GetPage with some rules: * We cannot support more than 2 arguments, i.e. .Site.GetPage "page" "posts" "mypage.md" will now throw an error. I think this is the most uncommon syntax and should be OK. It is an easy fix to change the above to .Site.GetPage "/posts/mypage.md" or similar. * .Site.GetPage "home", .Site.GetPage "home" "" and .Site.GetPage "home" "/" will give you the home page. This means that if you have page in root with the name home.md you need to do .Site.GetPage "/home.md" or similar This commit also fixes some multilingual issues, most notable it is now possible to do cross-language ref/relref lookups by prepending the language code to the path, e.g. `/jp/posts/mypage.md`. This commit also reverts the site building tests related to this to "Hugo 0.44 state", to get better control of the changes made. Closes gohugoio#4147 Closes gohugoio#4727 Closes gohugoio#4728 Closes gohugoio#4728 Closes gohugoio#4726 Closes gohugoio#4652
bep
added a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit is a follow up to a recent overhaul of the GetPage/ref/relref implemenation. The most important change in this commit is the update to `.Site.GetPage`: * To reduce the amount of breakage in the wild to its minimum, I have reworked .Site.GetPage with some rules: * We cannot support more than 2 arguments, i.e. .Site.GetPage "page" "posts" "mypage.md" will now throw an error. I think this is the most uncommon syntax and should be OK. It is an easy fix to change the above to .Site.GetPage "/posts/mypage.md" or similar. * .Site.GetPage "home", .Site.GetPage "home" "" and .Site.GetPage "home" "/" will give you the home page. This means that if you have page in root with the name home.md you need to do .Site.GetPage "/home.md" or similar This commit also fixes some multilingual issues, most notable it is now possible to do cross-language ref/relref lookups by prepending the language code to the path, e.g. `/jp/posts/mypage.md`. This commit also reverts the site building tests related to this to "Hugo 0.44 state", to get better control of the changes made. Closes gohugoio#4147 Closes gohugoio#4727 Closes gohugoio#4728 Closes gohugoio#4728 Closes gohugoio#4726 Closes gohugoio#4652
bep
added a commit
to bep/hugo
that referenced
this issue
Jul 17, 2018
This commit is a follow up to a recent overhaul of the GetPage/ref/relref implemenation. The most important change in this commit is the update to `.Site.GetPage`: * To reduce the amount of breakage in the wild to its minimum, I have reworked .Site.GetPage with some rules: * We cannot support more than 2 arguments, i.e. .Site.GetPage "page" "posts" "mypage.md" will now throw an error. I think this is the most uncommon syntax and should be OK. It is an easy fix to change the above to .Site.GetPage "/posts/mypage.md" or similar. * .Site.GetPage "home", .Site.GetPage "home" "" and .Site.GetPage "home" "/" will give you the home page. This means that if you have page in root with the name home.md you need to do .Site.GetPage "/home.md" or similar This commit also fixes some multilingual issues, most notable it is now possible to do cross-language ref/relref lookups by prepending the language code to the path, e.g. `/jp/posts/mypage.md`. This commit also reverts the site building tests related to this to "Hugo 0.44 state", to get better control of the changes made. Closes gohugoio#4147 Closes gohugoio#4727 Closes gohugoio#4728 Closes gohugoio#4728 Closes gohugoio#4726 Closes gohugoio#4652
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Unix-style path semantics, in particular support for both absolute and relative paths, are well understood and have become the path "lingua franca", from file systems to HTML links. Hugo's
.Site.GetPage
method andref
/relref
shortcodes go against these conventions:The latter adds unnecessary confusion for new users. The former is a significant functional disadvantage. Relative paths allow sections (directory branches) in the content tree to be self-contained, and facilitate moving or renaming them without breaking internal links. It is one of the main reasons HTML follows unix-style path semantics (and given that HTML is Hugo's most common target, it would be nice to have the same semantics).
relative path vs shorthand references
Hugo supports what I'm calling "shorthand" refs for the
.Site.GetPage
method and theref
/relref
shortcodes. I'm not sure it was a good idea.Looking at the discussion, shorthand refs came about to alleviate a pain point: One had to type the fully-qualified, absolute (from the content root) path to the target, no matter how deep, and even if one page was referring to another page in the same directory.
Supporting relative paths would have alleviated that pain without introducing ambiguity, and in a way that is arguably more powerful.
To re-use the example from #4727:
help.md
links
andtags
./help.md
and the homepage as/
. The "/" prefix says with a single char: I am referring to a root item!../
. That three character prefix says I'm pointing back out to my containing section, and it will work even if Lessons is renamed to Tutorials.links/help.md
andtags/help.md
./blog/lessons.md
is not only reasonable but perfect. If you think about it, such cross-branch links are the kind of links you really want to be explicit about and fully-qualify...
or/lessons
, depending on whether you are saying I'm pointing to my parent section or I'm pointing to the lessons section.if you really want wiki links...
The reason wiki links can be so simple is because wikis have a single, flat namespace (see discussion here). It's really dangerous to collapse the hierarchical namespace of a filesystem into a flat namespace. You can achieve wiki-like simplicity with Hugo: Just put all your content in the root folder, in which case you only ever have to type the filename. If Hugo supported relative paths, you could do this in a section or subsection as well.
Pull request forthcoming pending a discussion on the forum...
The text was updated successfully, but these errors were encountered: