Skip to content
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

Support references to homepage and sections with ref/relref #4147

Closed
MichaelHierweck opened this issue Dec 3, 2017 · 7 comments
Closed

Support references to homepage and sections with ref/relref #4147

MichaelHierweck opened this issue Dec 3, 2017 · 7 comments

Comments

@MichaelHierweck
Copy link

Ref/relref should support linking to homepage and sections (at least when _index.md exists).

@bep
Copy link
Member

bep commented Dec 3, 2017

Have you checked that this issue does not already exist?

@MichaelHierweck
Copy link
Author

Yes, I have.

@estinchon
Copy link

+1

@nidrissi
Copy link

nidrissi commented Mar 7, 2018

One example where it would be useful: I enabled "defaultContentLanguageInSubdir" on my website -> boom, dozens of deadlinks that I had to fix manually, because all the links to sections were hardcoded.

@vassudanagunta
Copy link
Contributor

(copied from description of #4725, which I closed as a dupe of this issue)

The raison d'être of the ref/relref shortcodes is to enable pages to link to other pages without knowing in advance their eventual publish URL. This is not only important from a separation of concerns perspective, but it is critical given that the publish URL can be arbitrarily modified a number of ways: by Hugo permalink configuration, or by url or slug front matter params, or switching between pretty and ugly URLs.

Prior to v0.33, the url front matter param was only supported for regular pages. The ref/relref shortcodes weren't necessary for links to section or taxonomyTerm pages. But v0.33 changed this:

Hugo now respects the url value in front matter for all page types, including sections.  Also, you can now configure uglyURLs per section.

Currently there is no way to link to a section or taxonomyTerm page independent of final publish URL. The fix is to update ref/relref shortcodes to support all page kinds. This also lends to greater API consistency.

Related Forum topic: How to link to section pages with ref/relref shortcodes?

Pull request with my implementation forthcoming...

@vassudanagunta
Copy link
Contributor

I've implemented this, but the pull requests is pending some questions I need answered. See the the discussion on the forum.

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 bep added this to the v0.45 milestone Jul 17, 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.

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
bep pushed a commit 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 #4147
See #4727
See #4728
See #4728
See #4726
See #4652
@bep bep closed this as completed in 3eb313f Jul 17, 2018
@github-actions
Copy link

github-actions bot commented Mar 1, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants