# Embedding with multiple categories?

**URL:** https://meta.discourse.org/t/embedding-with-multiple-categories/31450
**Category:** Feature
**Created:** [26 juli 2015 om 18:53 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450 "2015-07-26T18:53:21Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![JamesChevalier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jameschevalier/32/116235_2.png) [@JamesChevalier](https://meta.discourse.org/u/JamesChevalier)
#### Post date: [26 juli 2015 om 18:53 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/1 "2015-07-26T18:53:21Z")

</div>

The current method of embedding discourse into another site requires a single category be selected for all embeds. This is done in Admin → Embedding, by setting the `embed category` value.

Are there plans to allow multiple categories be used for multiple embeds, or is there a way to do that currently?

The scenario I have is a single host/site (not WordPress) that I’d like to embed Discourse in, which has a few separate sections. The comments within each section in that site should go to different categories within the Discourse site.

---

<div class="post-metadata">

### Author: ![fantapop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantapop/32/121823_2.png) [@fantapop](https://meta.discourse.org/u/fantapop)
#### Post date: [12 november 2015 om 03:32 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/2 "2015-11-12T03:32:40Z")

</div>

I’m also interested in this functionality. Did you ever find a way? It seems like passing a category Id along with the embed request would be a reasonable option.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [12 november 2015 om 05:14 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/3 "2015-11-12T05:14:27Z")

</div>

Pretty sure we support this now, don’t we @eviltrout?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [12 november 2015 om 16:09 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/4 "2015-11-12T16:09:26Z")

</div>

We’ve improved this a bit. You can now choose to embed [certain hosts to certain categories](https://meta.discourse.org/t/new-embedding-page-with-support-for-host-arrow-right-category/32344). Would that work for you?

Adding the category to the embed options would be insecure as they could be spoofed.

---

<div class="post-metadata">

### Author: ![fantapop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantapop/32/121823_2.png) [@fantapop](https://meta.discourse.org/u/fantapop)
#### Post date: [12 november 2015 om 18:24 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/5 "2015-11-12T18:24:44Z")

</div>

In this case, We have different sections on a site hosted with the same subdomain (in this case www). It would be nice if comments on a new blog post would open a new Blog Comments category topic and new comments on a bundle would open a new Bundle category topic. We’re able to work around the issue manually by creating topic ahead of time for each Bundle and then passing the topic id along with the embed data.

Would it still be insecure if the category had to pre-exist and if the embed config specified a list of categories each domain would work for?

---

<div class="post-metadata">

### Author: ![JamesChevalier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jameschevalier/32/116235_2.png) [@JamesChevalier](https://meta.discourse.org/u/JamesChevalier)
#### Post date: [12 november 2015 om 18:56 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/6 "2015-11-12T18:56:20Z")

</div>

My situation is similar to @fantapop.

If that host configuration could go down a level into the URL structure that would work for me.  
For example:

- comments for any URL below [http://example.com/this-thing](http://example.com/this-thing) would go into the ‘this-thing’ category
- comments for any URL below [http://example.com/that-thing](http://example.com/that-thing) would go into the ‘that-thing’ category

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [13 november 2015 om 17:16 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/7 "2015-11-13T17:16:47Z")

</div>

> [@fantapop](#):
>
> Would it still be insecure if the category had to pre-exist and if the embed config specified a list of categories each domain would work for?

At that point the worst that could happen is a user creates something in the wrong category. It’s not a security hole but it’s still annoying if your users can troll you that way.

It sounds like there are two ways I could solve this:

1. We add another configuration option which is a relationship between paths on a host and categories.

2. We embed something in the source document that specifies the category. For example a meta tag. When discourse crawls the document it sees the category in the meta and places it there.

Both would require some work but are doable.

---

<div class="post-metadata">

### Author: ![fantapop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantapop/32/121823_2.png) [@fantapop](https://meta.discourse.org/u/fantapop)
#### Post date: [13 november 2015 om 20:19 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/8 "2015-11-13T20:19:41Z")

</div>

Both of those sound like reasonable options. Option 2 sounds a little easier to use and that it might fit into the current embed UX a little better than option 1. Thanks for your time.

---

<div class="post-metadata">

### Author: ![robalan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robalan/32/122069_2.png) [@robalan](https://meta.discourse.org/u/robalan)
#### Post date: [30 november 2015 om 22:02 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/9 "2015-11-30T22:02:47Z")

</div>

Would the meta tag be something that we set in the embed script? This would be really useful.

---

<div class="post-metadata">

### Author: ![JamesChevalier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jameschevalier/32/116235_2.png) [@JamesChevalier](https://meta.discourse.org/u/JamesChevalier)
#### Post date: [17 januari 2016 om 17:50 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/10 "2016-01-17T17:50:05Z")

</div>

What does it look like when you embed the topic id along with the embed data? Are you using a different `discourseUrl` in the script?

It sounds like you have something working, but I can’t conceptualize it. Would you be able to explain your setup?

---

<div class="post-metadata">

### Author: ![fantapop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantapop/32/121823_2.png) [@fantapop](https://meta.discourse.org/u/fantapop)
#### Post date: [18 januari 2016 om 03:51 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/11 "2016-01-18T03:51:00Z")

</div>

We end up passing the same discourseUrl which is the instance of discourse. Then we pass either a discourseEmbedUrl or a topicId along depending on which section of the site the comments will be going in. The topic id is added to the dom during page render if it already exists.

Here is a code snippet

```
        var TOPIC_ID_ATTR = 'data-discourse-topic-id';

        var shareUrl = $('meta[property="og:url"]').attr('content'),
            topicId = $('[' + TOPIC_ID_ATTR + ']');

        var embedConfig = {
            discourseUrl: <forumUrl>
        };

        if (topicId.length > 0) {
            embedConfig.topicId = parseInt(topicId.attr(TOPIC_ID_ATTR));
        }
        else {
            embedConfig.discourseEmbedUrl = shareUrl;
        }

        window.DiscourseEmbed = embedConfig;

```

---

<div class="post-metadata">

### Author: ![JamesChevalier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jameschevalier/32/116235_2.png) [@JamesChevalier](https://meta.discourse.org/u/JamesChevalier)
#### Post date: [19 januari 2016 om 02:58 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/12 "2016-01-19T02:58:23Z")

</div>

Woah, I didn’t know you could specify a `topicId` like that. I went hunting around and found [this post](https://meta.discourse.org/t/enhancements-to-embedding-comments/29822) which covers it, if anyone else is interested in further details.

Thanks for sharing this setup, @fantapop!

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [4 december 2025 om 11:36 UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/13 "2025-12-04T11:36:51Z")

</div>


