Watched words - replace link/url works in test but not in post

AI-generated summary

Watched Words URL Replacement Issue

janbolmeson reported that Watched Words URL replacement doesn’t work in posts, despite the Test button showing successful replacement.

SaraDev explained that remapping links using Watched Words is not recommended and has been disabled. Instead, two alternative solutions are proposed:

  • Adding links to the “Require Approval” section to manually update them in the review queue
  • Using the rake posts:remap["find","replace"] command to remap links across all posts

janbolmeson acknowledged the explanation and will solve the issue accordingly. SaraDev suggested updating the Watched Words Test button UI to indicate that links/URLs will not be remapped.

Maybe this is me doing something wrong, but I don’t seem to get watched word replace (or link) work with urls.

To recreate:

  1. In watched_words section I add this to word: https://example.com to look for
  2. And this to replace with: https://domain.com/?url=https://example.com

That is:
image

When I use the Test-button, it works:

But when I test the same in a post, it doesn’t match.

Hi Jan,

Remapping links through the use of watched words is not recommended, and can sometimes cause more trouble than intended, so we’ve disabled the ability to do so using Watched Words → Replace settings, and links will not be remapped in topics or posts regardless of watched word settings.

if you’re looking to remap links on your site there’s a couple other options we recommend for this.

The first option would be to still use Watched Words, but to add the links or urls to the “Require Approval” section instead of “Replace”. This would cause posts containing the links to be remapped to appear within the review queue, which you could then go through and update the links manually through the review queue.

Alternatively, there’s a rake posts:remap["find","replace"] command that you can run to remap or replace links (or specific text) on your site across all posts. For reference, we have more information about the remap command available here: Replace a string in all posts

With that in mind, I think the trouble here is that the Watched Words Test button seems to show that links/URLs will be remapped in posts, which is not the intended use case.

The test window should be true to reality, so perhaps we could make some small changes to the test window UI to indicate that links/urls will be NOT be remapped?

2 Likes

Thank you good explanations. I understand and will solve it accordingly! :+1:

1 Like