Possible to suffix all URLs matching a specific pattern?

I’m not sure if Hugo has the ability to do this… maybe via a custom module? For specific domains, I’d like to include specific things at the end of a URL, like UTM codes.

A massive search-replace with regex is possible thanks to all content being text, but not adding them to existing content would be ideal so you didn’t have to think about it in the future.

Are the original (un-modified) URLs specified in your markdown?

If yes, please provide an example of the original URL and what you want it to be.

Yup… for example, let’s say I have a podcast (on one site) that promotes my/affiliate products, but I need to reference how they got there. So let’s say I have links in my markdown that point to:

What I want is to not change the content in markdown, but rather just have something that runs like a post-process that adds UTM codes, like:

Ideally, I’d have a list of domains (mybusiness.com / affiliatebiz.com) that a post-process looks up and if it finds a URL, it would add the URL parameters to an existing querystring.

The brute force solution, which I can do, but would prefer to avoid, is to write a regex that does a global search & replace, but that only addresses existing content, not new content (that I’ll have to remember to add the URL to).

This can be accomplished with a markdown render hook. I would store the lookup table as a data file.

1 Like

Perfect… that’s exactly what I was looking for. I was blanking on the term. Thanks!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.