Plugin Suggestion: Wiki Links

During Micro Camp, @pimoore suggested a section here to post suggestions for MB plugins. So here’s one from me until we have a dedicated section:

Wiki Links - automatically links certain words/phrases to URLs that you specify in settings. E.g., if I mentioned SXSW EDU in a post, it should automatically link to Users can set as many or as few as they want in the settings.

I think the only way to do something like this in Hugo would be to have a block like:

{{ .Content | replaceRE … | replaceRE … | … }} with a regular expression for every expansion, and with this replacing {{ .Content }} in any theme. That doesn’t feel very doable for a plugin.

I’ve done some more digging here, and based on what I’ve found, I think I’m right this is not really possible with Hugo. Here’s an example someone used to auto link any URLs on their site. There are several posts on the Hugo forums about this as well and it seems clear this is not yet possible unless I’m using the wrong search terms to find newer content.

The automatic link part of this request might be doable. If not on the Hugo side, at least on the client-side using JavaScript. But I’m with @jsonbecker; it will probably not be particularly easy or elegant implementation-wise.

What I see as the biggest challenge with ideas like this is providing a user-friendly interface to manage the plug-in. We are constrained to what we can build on the plug-in’s settings page as third-party developers.

In this case, @pratik is asking for dynamic fields. A list of phrase/URL pairs that can range from 0 to ∞. That’s impossible today, and something @manton would need to add support for. We could work around this with something less user-friendly, like a big text field where one would have to enter JSON.

To summarize: a plug-in like this is not impossible to realize. But it would be a bit hacky behind the scenes, and the user experience would be subpar.

Oh well. Thanks for explaining.