# Tagsname as H2

**URL:** https://meta.discourse.org/t/tagsname-as-h2/273935
**Category:** Development
**Tags:** tags
**Created:** [August 4, 2023, 8:55am UTC](https://meta.discourse.org/t/tagsname-as-h2/273935 "2023-08-04T08:55:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fuchs](https://avatars.discourse-cdn.com/v4/letter/f/bcef8e/32.png) [@fuchs](https://meta.discourse.org/u/fuchs)
#### Post date: [August 4, 2023, 8:55am UTC](https://meta.discourse.org/t/tagsname-as-h2/273935/1 "2023-08-04T08:55:01Z")

</div>

Is it possible to insert an H2 heading in the tags area? The H2 heading should be the name of the tag.

I can’t use the tags banner component because the h2 is not on the side of the right sidebar, it’s above.

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/8/f/78ff40c9c7417571760f5dc305589ddd86a18cab.png)

---

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [August 4, 2023, 3:26pm UTC](https://meta.discourse.org/t/tagsname-as-h2/273935/2 "2023-08-04T15:26:18Z")

</div>

Write some code to achieve what you need. Here I have written a simple solution for you. Try it, it should do what you want

```javascript
<script type="text/x-handlebars" data-template-name="/connectors/discovery-list-controls-above/tag-h2">
<h2>
    {{#if h2_tag}}
        {{h2_tag}}
    {{/if}}
</h2>
</script>

<script type="text/discourse-plugin" version="0.8">
api.registerConnectorClass("discovery-list-controls-above", "tag-h2", {
  setupComponent(args, component) {
    if (window.location.pathname?.startsWith("/tag/"))
        component.set("h2_tag", /\/tag\/([^?]+)/.exec(decodeURI(window.location.pathname)).at(1));
  },
});
</script>

```

---

<div class="post-metadata">

### Author: ![fuchs](https://avatars.discourse-cdn.com/v4/letter/f/bcef8e/32.png) [@fuchs](https://meta.discourse.org/u/fuchs)
#### Post date: [August 4, 2023, 7:22pm UTC](https://meta.discourse.org/t/tagsname-as-h2/273935/3 "2023-08-04T19:22:27Z")

</div>

Oh thank you very much!! It’s working for the first tag I click on but if I change to another tag the h2 does not change.

---

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [August 6, 2023, 6:31am UTC](https://meta.discourse.org/t/tagsname-as-h2/273935/4 "2023-08-06T06:31:38Z")

</div>

Oh sorry this is my problem. I made some adjustments for this

```javascrupt
<script type="text/x-handlebars" data-template-name="/connectors/discovery-list-controls-above/tag-h2">
<h2>
    {{#if h2_tag}}
        {{h2_tag}}
    {{/if}}
    {{log this}}
</h2>
</script>

<script type="text/discourse-plugin" version="0.8">
api.registerConnectorClass("discovery-list-controls-above", "tag-h2", {
  setupComponent(args, component) {
    
    function getTagNameFromURL(url) {
        return /\/tag\/([^?]+)/.exec(decodeURI(url)).at(1)
    }  
    
    if (window.location.pathname?.startsWith("/tag/"))
        component.set("h2_tag", getTagNameFromURL(window.location.pathname));
    api.onPageChange(url => component.set("h2_tag", getTagNameFromURL(url)))
  },
});

</script>

```
