Automatic Internal Linking based on Keywords

Not entirely sure about how you could configure the automatic part of your question.

Have a look at: Links and Cross References | Hugo

Also the function relref | Hugo

A hacky workflow that comes to mind, would be to:

  • Store an array of these keywords in a parameter of the project’s config.
  • Use the replace or replaceRE functions to check up the .Content of Single Pages
  • When encountered, the keywords will be wrapped in HTML links markup, that will point to a Related Content File.
  • However since there may be more than one Related Content links you would most likely need to pick a single one (at random) by piping the Related Content links with the uniq function.

It would be quite complicated even for me to put the above together and I am only spitballing here.

I don’t think that as beginner you want to follow that path, also because depending on a project’s size the above may slow down the project build time (or it may not).

Perhaps others can offer more informed suggestions to your question.

2 Likes