Skip to content

Rewrite markdown links to HTML

Sarah German requested to merge 52-link-filter into main

What does this MR do and why?

Adds a markdown render hook to rewrite links to .md files as links to their corresponding HTML pages.

Hugo doesn't have anything built-in for this, but one of Hugo's maintainers has an example (https://github.com/bep/portable-hugo-links), which I mostly just copied over as-is.

The only modification I made here was to drop this: {{ if $isRemote }} target="_blank"{{ end }}. We do not open links in new tabs (see Pajamas: https://design.gitlab.com/components/link#behavior).

Please note: Links to pages that end in index.md do not work yet (e.g, the "issue tracker" link in the first paragraph of this page). This is because we have to rename all index.md files to _index.md to work with Hugo. While we are already renaming the files themselves, we're going to need to update all links accordingly. This is harder than it sounds, so I've created a follow-up here: #62 (closed). Also related: #55 (closed).

Closes #52 (closed)

Screenshots, screen recordings, or links to review app

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/technical-writing-group/gitlab-docs-hugo/-/blob/main/doc/setup.md.
  2. Update your local content and run the site: REMOVE_BEFORE_CLONE=true make clone-docs-projects && make view
  3. Visit a few pages and verify that links to other pages are functional (with the exception of links that end in index.md, see note in description)

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Achilleas Pipinellis

Merge request reports