-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Improve intra-site links (1) #19526
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve intra-site links (1) #19526
Conversation
/assign @zacharysarah @jimangel @kbarnard10 Assigning this to SIG chairs because this PR has some site wide implications. |
Deploy preview for kubernetes-io-master-staging ready! Built with commit d1a5b61 https://deploy-preview-19526--kubernetes-io-master-staging.netlify.app |
As a reference for how Hugo ref work: https://gohugo.io/content-management/cross-references/ |
This kind of commit is likely to trigger a conflict with work for v1.18 @tengqm you could have this PR target just |
c6ad252
to
4002252
Compare
I don't think this PR is anything different from a typo fix. It breaks nothing.
I was hoping that I can find out how many gochas out there when applying this change to more docs. A change on one page is not enough for this purpose. With this PR, if you review carefully, you will find out that:
|
Thanks @tengqm—you've answered and addressed my concerns around waiting for the v1.18 release. I endorse the aim of this PR: /approve |
@tengqm , I am reading through the changes. While this is an isolated PR, it seems as if you are proposing that this is an option for changing all intrasite links (and that more PRs would follow)? From, https://gohugo.io/content-management/cross-references/#use-rel-and-relref
|
That's a really good question. Maybe for a follow up PR? Maybe it needs to be in this one? |
To recap my understanding (which may be inaccurate) 😄 : Currently, each localized page has to modify the intrasite links on a page to point to a link that represents a localized version of some page. If the link is updated to point to a page that does not exist (not translated), that is a problem. The use of ref or relref will cause a build failure (Hugo) if there is not a translated page referred by the intrasite link? Will the link fall back to the English version of the page? What is the solution in this case. |
@kbhawkey Seems your understanding had been verified by the experiment I did in #18403. Missing page won't pass Hugo compilation. This might be a good thing because it means all dangling links in the localized sites are now detected as early as possible. In the experiment #18403, the Chinese version of Deployment page was missing. Hugo detected that and complained. |
At the moment, the style we have fills in the navigation with (marked) links to the English originals. I'd like to keep that behaviour. To me, serving an “under construction” type page with a 200 response wouldn't be an improvement. It'd be neat to use CSS or some other technique to highlight if a link is going to switch localization on the reader. |
@sftim If there is a strong opinion for auto-redirecting missing pages in localization to their corresponding English version, we can do that. Actually, this technology has been proposed before. We will need to introduce some shortcodes for that. I was not voting for that approach because I'm unsure whether the website team welcomes such code. |
Perhaps (separate PR): the 404 page can something like “sorry, /ko/docs/home/foobar/ is 404. [AJAX query] If you speak English, there's /docs/home/foobar/ though?” |
Some more thoughts: Back to the Hugo build question. If the OR create a static, localized "substitute" page for every missing page? |
The trouble then is that, as I understand it, Netlify will always serve that with a 200 status. If it were possible to serve a staticly rendered, relevant 404 page then I'd be really fine with that. It's very likely that there will be localizations with missing content and in the future I expect that to become more common. |
Not sure about this.
No idea. Current situation is that if we don't add the
No. Using
Hugo build will fail if and only if you are using
I'd go with placing a "to be localized page". If such a page can be reused by customizing Hugo, that would be great. Creating "placeholder" pages for every missing target is less ideal. I agree. If we can use |
Hi. I am reading about upgrading Hugo to take advantage of "portable links". Would this work or not? Introducing the |
@kbhawkey Thanks for the suggestion. I did take a look at the markdown render hooks and the example snippet. My current impression (could be wrong) is that it is not directly applicable to our multilingual case. The main concern to the approach proposed here, as commented previously, is about the handling of missing links. If we use the "markdown render hooks", we will be introducing some shortcode which has to deal with all kinds of links and all languages, while at the same time solving the missing links issue. Consider the following cases:
I'm not convinced that a simple render hook can resolve all of the above problems. |
@tengqm - in a SIG Docs meeting, @kbhawkey made a compelling case that Hugo could render traditional Markdown hyperlinks in a localization-friendly way:
Localizations might still want to adjust links that include fragment identifiers. However, most of the time when a localization adds a new page the rendering approach that @kbhawkey suggested sounds like it will let links to that new page “just work”. I hope you're convinced now that a different approach from this PR is that way forward. What are your thoughts? |
Hi @sftim @tengqm . I looked into this a bit further (PR #20114) and left some comments. |
Thanks for keeping the balls rolling ...
Totally agree.
There have been opinions that a mixture of English and localized content would be the case for a long time. That was also the reason why people wanted the "auto falling back to English" option.
Yup. Automation is difficult, if possible at all. That is why I tried to do all these conversions once for all, so that at least no localization team needs to handle redirected links or links to "foo/bar/_index.md" files.
So ... you mean for all French translations, we warn them that there are links not started with "https://" or "#" and they should be revised to "/fr/something"?
This is gonna be hard. We have many redirections in the English markdown. With all the above observations, I'm NOT implying that this PR is the best option going forward. The advantage of this PR is:
The cons, as I see it:
|
abandoned. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@tengqm Hi, wondering on how you change the whole directory link here? Any provided scripts to change the link for each of localization directory? |
@irvifa When I was working on this, I had to check each and every link in a markdown because I don't know how many variants out there. With this PR, I think I gained a better understanding of the types of links we need to deal with and the "proper" way to deal with them. Later on, @kbhawkey proposed a script (#21996) for identifying link problems. That is a good starting point. Maybe we can leverage that script to semi-automate this site-wide change. WDYT? |
@tengqm Yes, absolutely I agree with the leverage of doing semi-automate, however using site wide will cause a massive PR because it will affect all available localization, instead how about using that script only for each of the localization? This way each localization team can use the script autonomously and refrain the incoming massive PR. wdyt? |
Yes, it will be a pain in the short term. Just like what we have done for site theme changes. Once the change to English content is landed, no localization team need to customize each and every intra-site links. The revised links just work for all languages.
That brings us back to the intent of this PR. We can leave the English site as is. Then for all localization teams (there are 14 of them now), the same link will be changed 14 times, each by an individual localization team. Yes, script can help detect issues, hopefully. What I am trying to argue is that the primary reason we switched to Hugo was that Hugo has a "better" support for localization. Simply by replacing links like this
with something like this
ALL localization teams will benefit from it. Again, we have 14 localization teams now. |
@tengqm Understood, would you like to rebase your branch first? I see there’s lots of conflict |
This attempts to improve intra-site links so that the links can be automatically translated to localized versions. xref: kubernetes#18403 This PR is about the concepts/architecture and concepts/cluster-administration directories.
@@ -26,7 +26,7 @@ closer to the desired state, by turning equipment on or off. | |||
## Controller pattern | |||
|
|||
A controller tracks at least one Kubernetes resource type. | |||
These [objects](/docs/concepts/overview/working-with-objects/kubernetes-objects/#kubernetes-objects) | |||
These [objects]({{< ref "/docs/concepts/overview/working-with-objects/kubernetes-objects.md#kubernetes-objects" >}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this is literally should be the absolute path of the link. Also another nit: Probably we can give the best practices of writing links somewhere so others can adopt this way of writing a link? wdyt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The ref
shortcode requires the markdown file name. So there are pros and cons:
The benefits as I see it:
- By explicitly using file names in the links, we can avoid dangling links. For every links written this way, Hugo can help ensure the target does exists, and it can do so for every language translation.
- As a side-effect, we can kill some link targets that are actually redirects. For example,
[kube-apiserver](/docs/admin/kube-apiserver/)
has to be rewritten into[kube-apiserver]({{< ref "/docs/reference/command-line-tools-reference/kube-apiserver.md" >}})
.
The drawbacks is that rewriting the links is a tedious task because for each link we need to check:
- if the link
[foo](/docs/bar/)
is there, whether we do have[foo](/docs/bar.md)
in the file system. If not, we need to check, - if the target file
/docs/bar/_index.md
is there, and revise the link to[foo](/docs/bar/_index.md)
if so. Or - if we have an entry in
/static/_redirects
that says/docs/foo/ /docs/zoo/ 301
. We need to check/docs/zoo/
by repeating step 1 and 2. Or else, - we need to check if the target is of pattern
/docs/reference/generated/kube*
. We have to leave the target as is in this case because the target is not meant to be localized. The target file lives in/static/docs/...
directory. - finally, if the target itself contains a shortcode, we cannot change it. We have to leave it there. For example,
[latest version](/docs/path1/{{< latest-version >}}/path2)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I had given this some additional thoughts these days. Maybe I was too ambitious to start this thread. I'm not sure such a logic can find its home in GoHugo. Even if I can complete this in a week or so, how difficult it is for doc maintainers to check if all future link changes are obeying such a complicated rule, in order to be both valid and friendly to localization teams.
I'm myself kinda split on this. Maybe we should instead develop a script for this instead? Since we almost know all the gocha's out there, we can come up with a tool for all localization teams to use. Maybe such a tool can be combined with the link checking for English site as well? I don't know. I'm just dumping my brain here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seconded the idea of automation and link checker for this. Since we know the pattern forming automation will be easier since we know the possible gotchas hence we can address this by forming rigorous testing. Need your input on this @sftim wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm minded to look a little more to see if we can convert a hyperlink within a localization eg
that appears in Markdown as (say) /docs/tasks/tools/install-kubectl/
so that the rendered HTML has <a href="/eg/docs/concepts/docs/tasks/tools/install-kubectl/>…</a>
. In other words, the site handles the conversion automatically.
If that's feasible, that's my favorite option. There might be a change to get advice on this from the people behind Hugo, too.
If we had the automatic conversion in place, we could run a one-time script to clean up all of the links that manually include the localization code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know whom should we contact regarding this Hugo config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hugo has its own page about requesting help so that might be one place to turn.
I'd be delighted to learn that some other group that uses Hugo has already found this problem and prepared a good solution.
/close |
This attempts to improve intra-site links so that the links can be automatically translated to localized versions.
xref: #18403
This PR is about the concepts/architecture and concepts/cluster-administration directories.