diff --git a/docs/config/_default/params.toml b/docs/config/_default/params.toml index 093cf3b05b..9e53e9cbda 100644 --- a/docs/config/_default/params.toml +++ b/docs/config/_default/params.toml @@ -488,12 +488,6 @@ disableDefaultRelref = false # not be servable from the file system. disableExplicitIndexURLs = false -# Support legacy language links. -# Default: false -# If set to true, you can link to pages in other languages by using -# `/pir/my-page`. This is not recommended, use ``/my-page?lang=pir` instead. -enableLegacyLanguageLinks = false - # How to open external links. # Default: '_blank' # For external links you can define how they are opened in your browser. All diff --git a/docs/content/configuration/content/linking/index.en.md b/docs/content/configuration/content/linking/index.en.md index ba00b4c415..29d06402c6 100644 --- a/docs/content/configuration/content/linking/index.en.md +++ b/docs/content/configuration/content/linking/index.en.md @@ -1,7 +1,7 @@ +++ categories = ["howto"] description = "What options are available for links and images" -options = ["disableDefaultRelref", "disableExplicitIndexURLs", "enableLegacyLanguageLinks"] +options = ["disableDefaultRelref", "disableExplicitIndexURLs"] title = "Linking" weight = 4 +++ @@ -21,14 +21,6 @@ For the file system scenario, you are not allowed to change this value. disableExplicitIndexURLs = true {{< /multiconfig >}} -## Cross-Language Links - -You can link to pages of different languages by appending the `lang` query parameter with the language code to the URL, e.g. `/my-page?lang=pir`. - -In previous releases of the theme you had to prepend the language code to the URL, e.g. `/pir/my-page` to achieve this. - -If you still need the old behavior, you can set `enableLegacyLanguageLinks=true` in your `hugo.toml`. Note that this legacy feature may be removed in the future. - ## Patching the `relref` Shortcode {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} While the usage of `relref` is obsolete and discouraged by Hugo for a while, existing installations may still use it. diff --git a/docs/content/configuration/content/linking/index.pir.md b/docs/content/configuration/content/linking/index.pir.md index f3e3203208..7742d8d769 100644 --- a/docs/content/configuration/content/linking/index.pir.md +++ b/docs/content/configuration/content/linking/index.pir.md @@ -1,7 +1,7 @@ +++ categories = ["howto"] description = "What options are available for links and images" -options = ["disableDefaultRelref", "disableExplicitIndexURLs", "enableLegacyLanguageLinks"] +options = ["disableDefaultRelref", "disableExplicitIndexURLs"] title = "Linking" weight = 4 +++ diff --git a/docs/content/introduction/releasenotes/5/12.en.md b/docs/content/introduction/releasenotes/5/12.en.md index db188151e7..b423d0ba18 100644 --- a/docs/content/introduction/releasenotes/5/12.en.md +++ b/docs/content/introduction/releasenotes/5/12.en.md @@ -28,6 +28,6 @@ weight = -12 } ```` -- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Support for languages that are written right to left (like Arabic) is now complete and extended to the menu, the top navigation bar and print. You can experience this in the [pirate translation](/?lang=pir). This feature is not available in Internet Explorer 11. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Support for languages that are written right to left (like Arabic) is now complete and extended to the menu, the top navigation bar and print. You can experience this in the [pirate translation](/pir). This feature is not available in Internet Explorer 11. - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The scrollbars are now colored according to their variant color scheme to better fit into the visuals. diff --git a/docs/content/introduction/releasenotes/7/4.en.md b/docs/content/introduction/releasenotes/7/4.en.md index 913630df99..21ba730b89 100644 --- a/docs/content/introduction/releasenotes/7/4.en.md +++ b/docs/content/introduction/releasenotes/7/4.en.md @@ -10,14 +10,6 @@ weight = -4 ### Change -- {{% badge style="note" title=" " %}}Change{{% /badge %}} The way you [link to pages in a different language](configuration/content/linking#cross-language-links) has changed. Until now this was an undocumented feature. - - Previously you could prepend an URL with the language code, e.g. `/pir/my-page` to link to pages of other languages. This could cause problems if you have a page with the same name as the language code on the top level of your page structure. - - Now you have to set the query parameter `lang` to the language code, e.g. `/my-page?lang=pir`. - - As this was previously undocumented, most projects will not be affected. If you still need the old behavior, you can set `enableLegacyLanguageLinks=true` in your `hugo.toml`. - - {{% badge style="note" title=" " %}}Change{{% /badge %}} The `target` parameter of the [`button` shortcode](shortcodes/button#parameter) was deprecated. Use [link effects](authoring/markdown#link-effects) on the `href` parameter instead. You don't need to change anything as the old parameter still works but may generate warnings. diff --git a/layouts/partials/_relearn/linkObject.gotmpl b/layouts/partials/_relearn/linkObject.gotmpl index 726869fdd2..7a08aa31c2 100644 --- a/layouts/partials/_relearn/linkObject.gotmpl +++ b/layouts/partials/_relearn/linkObject.gotmpl @@ -1,61 +1,48 @@ -{{- $linkObject := "" }} -{{- $u := urls.Parse .url }} -{{- $path := strings.TrimPrefix "./" $u.Path }} -{{- $searchLocal := .searchLocal | default true }} -{{- $searchGlobal := .searchGlobal | default true }} -{{- $searchPage := .searchPage | default true }} -{{- $searchResource := .searchResource | default true }} -{{- $site := .page.Site }} -{{- $page := .page }} -{{- $transSite := "" }} -{{- $transPage := "" }} -{{- $lang := $u.Query.Get "lang" }} -{{- if and $site.Params.enableLegacyLanguageLinks (not $lang) }} - {{- /* is it a legacy link into another translation? */}} - {{- if strings.HasPrefix $path "/" }} - {{- range $site.Sites }} - {{- $lang = .Language.Lang }} - {{- $prefix := printf "/%s" $lang }} - {{- $suffix := strings.TrimPrefix $prefix $path | default "/" }} - {{- /* with the second check we check if the prefix was finished; - eg. /pir/index.html vs. /pirate/index.html, were the latter is - an external address outside of this site */}} - {{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }} - {{- $path = $suffix }} - {{- $transSite = . }} - {{- break }} - {{- end }} - {{- end }} - {{- end }} - {{- if not $transSite }} - {{ $lang = $site.Language.Lang }} - {{ $transSite = $site }} - {{- end }} -{{- else if $lang }} - {{- with where $site.Sites "Language.Lang" "eq" $lang }} - {{- with index . 0 }} - {{- $transSite = . }} - {{- end }} - {{- end }} -{{- else }} - {{ $lang = $site.Language.Lang }} - {{ $transSite = $site }} -{{- end }} -{{- if $transSite }} - {{- $transPage = $transSite.GetPage $page.Path }} - {{- if $path }} - {{- with or - (and $searchLocal $searchPage $transPage ($transPage.GetPage $path)) - (and $searchLocal $searchPage $transPage ($transPage.GetPage (strings.TrimRight "/" $path))) - (and $searchGlobal $searchPage ($transSite.GetPage $path)) - (and $searchGlobal $searchPage ($transSite.GetPage (strings.TrimRight "/" $path))) - (and $searchLocal $searchResource $transPage ($transPage.Resources.Get $path)) - (and $searchGlobal $searchResource (resources.Get $path)) - }} - {{- $linkObject = . }} - {{- end }} - {{- else if $searchPage }} - {{- $linkObject = $transPage }} - {{- end }} -{{- end }} +{{- $page := .page }} +{{- $linkObject := "" }} +{{- $u := urls.Parse .url }} +{{- $path := strings.TrimPrefix "./" $u.Path }} +{{- $searchLocal := .searchLocal | default true }} +{{- $searchGlobal := .searchGlobal | default true }} +{{- $searchPage := .searchPage | default true }} +{{- $searchResource := .searchResource | default true }} +{{- if $path }} + {{- with or + (and $searchLocal $searchPage ($page.Page.GetPage $path)) + (and $searchLocal $searchPage ($page.Page.GetPage (strings.TrimRight "/" $path))) + (and $searchGlobal $searchPage (site.GetPage $path)) + (and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path))) + (and $searchLocal $searchResource ($page.Page.Resources.Get $path)) + (and $searchGlobal $searchResource (resources.Get $path)) + }} + {{- $linkObject = . }} + {{- else }} + {{- /* is it a link into another translation? */}} + {{- if strings.HasPrefix $path "/" }} + {{- range $page.AllTranslations }} + {{- $lang := .Language.Lang }} + {{- $prefix := printf "/%s" $lang }} + {{- $suffix := strings.TrimPrefix $prefix $path | default "/" }} + {{- /* with the second check we check if the prefix was finished; + eg. /pir/index.html vs. /pirate/index.html, were the latter is + an external address outside of this site */}} + {{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }} + {{- with or + (and $searchLocal $searchPage (.GetPage $suffix)) + (and $searchLocal $searchPage (.GetPage (strings.TrimRight "/" $suffix))) + (and $searchGlobal $searchPage (site.GetPage $path)) + (and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path))) + (and $searchLocal $searchResource (.Resources.Get $suffix)) + (and $searchGlobal $searchResource (resources.Get $suffix)) + }} + {{- $linkObject = . }} + {{- break }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} +{{- else }} + {{- $linkObject = $page.Page }} +{{- end }} {{- return $linkObject }} \ No newline at end of file diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index 09967b4c45..231904b2a6 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.3.2+881931eb115fdf80beeaa72bb39825805d36a77c \ No newline at end of file +7.3.2+5f9fee85c496d624b916f206a0e97bf0861fe268 \ No newline at end of file