# Tag description is removing target="\_blank"

**URL:** https://meta.discourse.org/t/tag-description-is-removing-target-blank/375263
**Category:** Support
**Created:** [July 22, 2025, 4:31pm UTC](https://meta.discourse.org/t/tag-description-is-removing-target-blank/375263 "2025-07-22T16:31:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alltiagocom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alltiagocom/32/492709_2.png) [@alltiagocom](https://meta.discourse.org/u/alltiagocom)
#### Post date: [July 22, 2025, 4:31pm UTC](https://meta.discourse.org/t/tag-description-is-removing-target-blank/375263/1 "2025-07-22T16:31:03Z")

</div>

On some of my tags’ descriptions I want to add a link like this:

```html
<a href="https://store.sgiant.me" target="_blank">Click here</a> to visit the official Sir Giant store.

```

When I first save it, it works and it opens in a new window.  
When I refresh the page, it doesn’t work anymore and when I check the code, it becomes:

```html
<a href="https://store.sgiant.me">Click here</a> to visit the official Sir Giant store.

```

I already have that option to open external links in a new tab set to Yes, but this seems to not affect this particular case where I’m adding html code.

ChatGPT suggested the creation of a component with the JS tab containing:

```javascript
import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {
  function processTagLinks() {
    document.querySelectorAll('.tag-title-contents a[href^="http"]').forEach(link => {
      if (!link.href.includes(window.location.hostname) && !link.hasAttribute('data-processed')) {
        link.setAttribute('target', '_blank');
        link.setAttribute('rel', 'noopener noreferrer');
        link.setAttribute('data-processed', 'true');
      }
    });
  }

  // Process immediately
  processTagLinks();

  // Watch for DOM changes
  const observer = new MutationObserver(() => {
    processTagLinks();
  });

  observer.observe(document.body, {
    childList: true,
    subtree: true
  });

  // Also run on page changes
  api.onPageChange(() => {
    setTimeout(processTagLinks, 100);
  });
});

```

But I’m no developer and so I don’t know if that’s a good solution or not?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 22, 2025, 6:26pm UTC](https://meta.discourse.org/t/tag-description-is-removing-target-blank/375263/2 "2025-07-22T18:26:12Z")

</div>

Maybe you just want to adjust `Default other external links in new tab`

---

<div class="post-metadata">

### Author: ![alltiagocom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alltiagocom/32/492709_2.png) [@alltiagocom](https://meta.discourse.org/u/alltiagocom)
#### Post date: [July 22, 2025, 6:45pm UTC](https://meta.discourse.org/t/tag-description-is-removing-target-blank/375263/3 "2025-07-22T18:45:41Z")

</div>

> [@pfaffman](#):
>
> Default other external links in new tab

But that’s what I mean by `I already have that option to open external links in a new tab set to Yes`

![image](https://global.discourse-cdn.com/meta/original/4X/9/d/9/9d92feb256046e67982752eecade7e153048ab1b.png)

This doesn’t affect the raw HTML I’m using in the description. That’s why I had to find an alternative.
