# Get topic id when the topic show page loads

**URL:** https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620
**Category:** Development
**Created:** [June 22, 2020, 9:05pm UTC](https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620 "2020-06-22T21:05:32Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![JQ331](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@JQ331](https://meta.discourse.org/u/JQ331)
#### Post date: [June 23, 2020, 3:45pm UTC](https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620/10 "2020-06-23T15:45:14Z")

</div>

Thanks. I’m familiar with some of the basics you mention, but there’s one point that gets me stuck (and I bet this kind of thing gets a lot of people stuck):

On the topic show page, it loads the template /templates/components/topic-category.hbs. That’s what displays the category and also the tag beneath the topic title.

In topic-category, it lists out `topic.tags`. So that’s the key piece of info I need to get this going.

Here’s where I am stuck: **How can I get that topic.tags information to my javascript?**

For example, if I just wanted to console.log the contents of topic.tags, how would I do that?

* * *

I know how to override templates. For example, in a theme, I could put in a file at `discourse/templates/components/topic-category.hbs`, and reprint the template there, adding in changes I wanted to make to the view. (I’m using the separate file structure described [here](https://meta.discourse.org/t/splitting-up-theme-javascript-into-multiple-files/119369)).

In my theme, I also know how to put javascript at `theme/initializers/initializer-file.js.es6`.

And I can make the two interact with some jquery. For example, I could put the topic.tags into a div in the template, and access that in my initializer with jquery by getting the content of that div.

But that’s round about. How can I get that topic.tags info directly so I can parse it and manipulate it?

---

_[View the full topic](https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620)._
