Skip to content

Prepare links for link validation#110

Open
thomasrebele wants to merge 2 commits into
apache:mainfrom
thomasrebele:tr/prepare-links
Open

Prepare links for link validation#110
thomasrebele wants to merge 2 commits into
apache:mainfrom
thomasrebele:tr/prepare-links

Conversation

@thomasrebele

@thomasrebele thomasrebele commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Use {{% ref "..." %}} instead of {{< ref "..." >}}, so that a future link validator will get the link before it is passed to Goldmark. The Goldmark renderer will replace the URL with a shortcode that cannot be validated anymore. (See https://discourse.gohugo.io/t/using-shortcode-inside-render-hook/42038/5).

The modifications have been done with the following command:

perl -pi -e 's/\{\{< (ref|relref) "([^"]*)" >\}\}/{{% \1 "\2" %}}/gm' **/*.md

(Previously it was perl -pi -e 's/\{\{< ref "([^"]*)" >\}\}/{{% ref "\1" %}}/gm' **/*.md. The updated command also handles relref links)

Use {{% ref "..." %}} instead of {{< ref "..." >}}, so that a future
link validator will get the link before it is passed to Goldmark.
The Goldmark renderer will replace the URL with a shortcode that cannot
be validated anymore.

Source:
https://discourse.gohugo.io/t/using-shortcode-inside-render-hook/42038/5

The modifications have been done with the following command:

perl -0pi -e 's/\{\{< ref "([^"]*)" >\}\}/{{% ref "\1" %}}/gm' **/*.md
@rubenada

Copy link
Copy Markdown

Just to double-check: there are 3 instances of {{< relref "…" >}}, which were not considered by this patch:

  • content/docs/latest/admin/iceberg-rest-catalog.md:28 ==> [Apache Hive : Setting Up OAuth 2]({{< relref "oauth2/_index.md" >}})
  • content/docs/latest/admin/iceberg-rest-catalog.md:44 ==> [Apache Hive : LanguageManual Authorization]({{< relref "../language/languagemanual-authorization.md" >}})
  • content/docs/latest/admin/oauth2/_index.md:16 ==> [Keycloak]({{< relref "keycloak.md" >}})

Are these intentionally excluded? Or should the also be change into {{% relref "…" %}} for consistency?

@thomasrebele

Copy link
Copy Markdown
Contributor Author

Thanks for checking. I guess it makes sense to include relref links as well. I've updated the PR, and the perl command in the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants