# Howto show the topic id in Metadata of initial Post

**URL:** <https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567>\
**Category:** Development\
**Created:** [July 4, 2017, 9:37am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567 "2017-07-04T09:37:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![nstoecki42](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nstoecki42/32/75218_2.png) [@nstoecki42](https://meta.discourse.org/u/nstoecki42)\
**Post date:** [July 4, 2017, 9:37am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/1 "2017-07-04T09:37:01Z")

</div>

I tried to display the Topic ID in the initial Post of all topics of a specific category but failed. I could not find a way by configuring Discourse and also a plugin - similar to [Discourse BBCODE](https://github.com/discourse/discourse-bbcode-color/) - failed to work.

Could you please give me a clear hint on how to realize to display the Topic ID in the initial Post metadata of each topic of a specific category?

 ![](https://global.discourse-cdn.com/meta/original/3X/4/c/4c3b4240f5909abd7a542f607f45d8de8f1f1b58.png)

I need this to continue the customer expectations of the old system as well some related functions and behavior.

Thanks a lot!

---

<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 4, 2017, 1:31pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/2 "2017-07-04T13:31:26Z")

</div>

The topic\_id is at the end of the URL.

Can you say more about what expectations you are tryingto may and what features you need?

---

<div class="post-metadata">

**Author:** ![nstoecki42](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nstoecki42/32/75218_2.png) [@nstoecki42](https://meta.discourse.org/u/nstoecki42)\
**Post date:** [July 4, 2017, 3:58pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/3 "2017-07-04T15:58:07Z")

</div>

As I mentioned in my Post I try to write a plugin, probably the #Development category is not the proper place due I don’t want this in Discourse itself. Can you point me to some kind of solution how to display additional (existing) meta data in the initial Post Header?

I know that the URL contains the TopicID as last “Tuple” and there is also a canonical link in the html header that does. I need to display the TopicID on the initial Post. We often speak about “Topic#34074” or something and want to stay with that habit, which our customers and partners are used to.  
So I tried to extract the ID (successfully) and past it into the ‘div.topic-meta-data’, which failed.

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [July 4, 2017, 4:34pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/4 "2017-07-04T16:34:17Z")

</div>

Add this to Settings \> Customize \> Common \> `</head>`:

```plaintext
<script type="text/discourse-plugin" version="0.5">
  api.decorateWidget('post-meta-data:after', dec => {
    if (dec.attrs.post_number === 1) {
      const topic = dec.getModel().get('topic');
      return dec.rawHtml(`<div class="post-info topic-id">Topic: ${topic.get('id')}</div>`);
    }
  });
</script>

```

And you get:

 ![](https://global.discourse-cdn.com/meta/original/3X/e/e/ee0692ecd4291b35f8fa3458b7ee8870122f4dc0.png)

And you just need to add some CSS.

---

<div class="post-metadata">

**Author:** ![nstoecki42](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nstoecki42/32/75218_2.png) [@nstoecki42](https://meta.discourse.org/u/nstoecki42)\
**Post date:** [July 4, 2017, 4:38pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/5 "2017-07-04T16:38:52Z")

</div>

of course, stylesheets are needed! 🕶

exactly what I’m looking for - thanks a lot!!! 🤗

---

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [October 17, 2019, 10:34am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/6 "2019-10-17T10:34:24Z")

</div>

Hello, Topic ID will show after post-meta-data  
I want show after title topic, how do it ?  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [October 17, 2019, 12:49pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/7 "2019-10-17T12:49:21Z")

</div>

You can just do ~~`component-name:after`~~ `widget-name:after`. Or use a plugin outlet if its available on the position you desire.

---

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [October 27, 2019, 1:37pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/8 "2019-10-27T13:37:52Z")

</div>

No effect ☹

```
<script type="text/discourse-plugin" version="0.5">
  api.decorateWidget('component-name:after', dec => {
    if (dec.attrs.post_number === 1) {
      const topic = dec.getModel().get('topic');
      return dec.rawHtml(`<div class="post-info topic-id">Topic: ${topic.get('id')}</div>`);
    }
  });
</script>

```

---

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [October 27, 2019, 1:39pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/9 "2019-10-27T13:39:33Z")

</div>

Did you actually literally put in ~~`component-name`~~ `widget-name` instead of the component’s actual name?

---

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [November 8, 2019, 9:26am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/10 "2019-11-08T09:26:44Z")

</div>

I wanna display topic ID below User name, what `widget-name` can i replace code 🙂  
Thank you!

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/5/0549dbafebbb89cd041840b7709dfa6668d35c3c.png)

---

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [November 14, 2019, 3:22am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/11 "2019-11-14T03:22:02Z")

</div>

Hello, who can i help me ☹

---

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [November 15, 2019, 10:43am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/13 "2019-11-15T10:43:50Z")

</div>

Did you try what Falco suggested in the above post?

---

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [February 12, 2020, 12:35pm UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/14 "2020-02-12T12:35:28Z")

</div>

Hello, how can we display count views topic in Post?

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

---

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [March 17, 2021, 8:48am UTC](https://meta.discourse.org/t/howto-show-the-topic-id-in-metadata-of-initial-post/65567/15 "2021-03-17T08:48:22Z")

</div>

Hello, who can help me display button Message move out topic

### js.user.private\_message

example:

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/1/f1fa6e28c018eb0f7e1cd8db072d24306c432653.png)
