I created custom module and it need to be able to change rendered html of each page on the site. I wand to change all external links. How I can realize it? Can I use hooks? How I can do in in right way?
I created custom module and it need to be able to change rendered html of each page on the site. I wand to change all external links. How I can realize it? Can I use hooks? How I can do in in right way?
The answer is to understand the Drupal templating system. Any Twig template on Drupal can be overridden with the current theme by copying the Twig-template into your theme and overriding the template content. You can also use theme_hooks with modules to override templates in modules instead of themes.
Take a look at the documentation: https://www.drupal.org/docs/theming-drupal/twig-in-drupal/working-with-twig-templates
For your specific link-Template you can use:
or depending on your base theme: