# Embedding Post: Can't read CSS Selectors from React Site

**URL:** https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316
**Category:** Support
**Tags:** embedding
**Created:** [September 17, 2023, 10:36pm UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316 "2023-09-17T22:36:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Aaron\_B](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_b/32/327391_2.png) [@Aaron\_B](https://meta.discourse.org/u/Aaron_B)
#### Post date: [September 17, 2023, 10:36pm UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316/1 "2023-09-17T22:36:49Z")

</div>

I have CSS tags on my content and have identified the CSS Selectors in the embedding admin settings but they are not being picked up by the crawler. I believe it is because my site is built with React and the css selectors are not accessible. How can I use this feature with a React site?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 17, 2023, 10:49pm UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316/2 "2023-09-17T22:49:01Z")

</div>

> [@Aaron\_B](#):
>
> I believe it is because my site is built with React and the css selectors are not accessible.

That may be the case although I’d expect the request that Discourse makes to the site to return HTML. Something else to look into is that Discourse caches the content that it’s pulled from the external site for 10 minutes. That means that if you are adjusting the `allowed embed selectors` site setting, you’ll have to wait up to 10 minutes to see the results of the new setting value.

If your Discourse site isn’t yet in production and you have access to the Discourse site’s Rails console, you can clear the cache from the console with `Rails.cache.clear`

Some additional details about the setting are here: [Configuring allowed embed selectors](https://meta.discourse.org/t/configure-the-allowed-embed-selectors-setting/134481/1).

Edit: I _think_ that embedding is working as expected. It’s just tricky to configure for some sites. I’m going to move this topic to #Support.

I created a #Contribute > Feature topic a few months ago suggesting that Discourse should find a better way of parsing embedded posts: [Topic embedding needs some love](https://meta.discourse.org/t/topic-embedding-needs-some-love/262763). I’ll put some time into that soon if no one gets to it before me.

---

<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: [September 20, 2023, 10:49am UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316/3 "2023-09-20T10:49:39Z")

</div>

Discourse presents a different view to crawlers. To see it you’ll need to visit with javascript turned off.

I would not expect embedded posts to be crawled since they do not exist on the site where they are embedded.

---

<div class="post-metadata">

### Author: ![Aaron\_B](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_b/32/327391_2.png) [@Aaron\_B](https://meta.discourse.org/u/Aaron_B)
#### Post date: [September 20, 2023, 12:35pm UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316/4 "2023-09-20T12:35:36Z")

</div>

Hello, I’m referring to how Discourse crawls my React site with the embedded posts feature. I’m having a hard time telling it what content to include on the Discourse post because of how it sees my React page.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 20, 2023, 4:52pm UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316/5 "2023-09-20T16:52:48Z")

</div>

> [@Aaron\_B](#):
>
> I’m referring to how Discourse crawls my React site with the embedded posts feature.

It it helps, the code that’s used for pulling in the external post is here: [discourse/app/models/topic\_embed.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/main/app/models/topic_embed.rb#L120-L230)

If you have access to your site’s Rails console, you can test it to get some idea of what’s going on. For example:

`TopicEmbed.find_remote("https://blog.discourse.org/2023/04/introducing-discourse-ai/")`

Where I’ve run into problems is with the `parse_html` method that’s called at the end of the `find_remote` method. Ruby Readability struggles with some HTML/CSS.

It’s also possible that HTML isn’t being returned from your React site. You could confirm that by running the code that’s in the `find_remote` method in steps from the console.

---

<div class="post-metadata">

### Author: ![Aaron\_B](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_b/32/327391_2.png) [@Aaron\_B](https://meta.discourse.org/u/Aaron_B)
#### Post date: [September 20, 2023, 6:23pm UTC](https://meta.discourse.org/t/embedding-post-cant-read-css-selectors-from-react-site/279316/6 "2023-09-20T18:23:51Z")

</div>

This is excellent, thank you!
