Support wiki internal link converson to relref shortcode

I am integrating the wiki of a GitHub project in a static site generated with Hugo and hosted on GitHub pages. This is my current scheme:

- [[Home|Home]]
- [[Data format(s)|Data-format(s)]]
- [[Desktop|Desktop]]
- [[Target platforms|Target-platforms]]
git clone "${REPO%.*}.wiki.git" content/wiki
cd content/wiki
sed -i -r 's/\[\[(.*)\|(.*)\]\]/[\1]({{< relref "wiki\/\" >}})/g' ./*.md

rm -rf .git
cd ../..

tar zxvf hugo_0.19_Linux-64bit.tar.gz && mv hugo_0.19_linux_amd64/hugo_0.19_linux_amd64 ./hugo_bin && rm -rf hugo_0.19_*

# Clean out existing contents
rm -rf out/**/* || exit 0

./hugo_bin -FED -d out
rm -rf hugo_bin

This behaves as expected, and I can browse the menu in the generated static site:

Note that the ‘NO MATCHING PARTIAL’ shown at the head of every content is because of the used tempate. Thus, it is a minor issue.

The advantage of this solution, compared to using shortcodes directly in the sources, is that doing so would break the visualization at the project’s wiki.

I’d like to integrate such a conversion pattern in Hugo. That is, to include an optional equivalent function to sed -i -r 's/\[\[(.*)\|(.*)\]\]/[\1]({{< relref "wiki\/\" >}})/g' ./*.md. However, I don’t know which would be the best approach:

  • Contribute to blackfriday and not to Hugo.
  • Make it default, if it doesn’t collide with other features.
  • Add a flag, so that it is (optionally) globally applied when hugo is executed.
  • Add a field to the frontmatter, so that the option is enabled in each document.
1 Like