Embedding a list of Discourse Topics in another site

What could one modify to specify multiple categories?

2 个赞

Should I expect this to work when the “other site” is running locally at http://localhost:8000 and the Discourse site is non-local on an https subdomain? Or would the “other site” also need to be on a “real” domain?

The script file appears to be fetched fine and I don’t see errors in the JS console. The “other site” is a Gatsby/React site; I’m adding the <d-topics-list> element once the page is rendered in the browser via useEffect, and it looks correct to me in the live DOM (see screenshot)…

Screen Shot 2021-05-19 at 9.21.08 AM

2 个赞

Going from https to http usually causes problems, but you can confirm by opening your browser console F12.

4 个赞

Aha, my issue appears to be that React is messing with the client-side DOM, resetting it to match the server-rendered DOM (with the raw <d-topics-list> element) immediately after the embed-topics.js script inserts the iframe.

5 个赞

Anyone know what this error is about??

Latest Discourse Build
Latest Chrome Browser

Refused to frame ‘https://vapingcommunity.co.uk/’ because an ancestor violates the following Content Security Policy directive: “frame-ancestors ‘self’”.

3 个赞

Most likely related to this change: (cc @falco)

Do you have your main site registered under Admin > Customize > Embedding?

7 个赞

Bingo! Didn’t see that change, all working perfectly again, thanks so much :wink:

5 个赞

是否有人遇到“拒绝加载”错误?

我启用了嵌入式主题,但出现

拒绝加载“https://myforumurl.com/”,因为祖先违反了以下内容安全策略指令:“frame-ancestors 'self'”。
1 个赞

您是想将整个论坛嵌入到另一个网站吗?那行不通。

OP 描述了如何在另一个网站上嵌入主题列表,但由于您描述的原因,您无法在 iframe 中运行 Discourse。

3 个赞

只需要最新的主题。我已按照说明在设置中启用嵌入式主题,并将脚本复制到托管网站的标题和正文中。不确定错误是否是由于我正在测试的开发站点没有 SSL 引起的。

3 个赞

这是由于您网站上的安全设置,而不是 Discourse 方面的设置。

4 个赞

搞定了。只是没有仔细阅读说明书 :slight_smile:

4 个赞

运行效果很好,我唯一的问题是谷歌正在索引 iframe 的 URL 本身

例如,我在此页面上嵌入了 Discourse 主题

谷歌似乎能正常索引上面的页面……但它也索引了下面的 URL,我希望修复这个问题

https://discuss.flynumber.com/embed/topics?discourse_embed_id=de-zse3f2nh3&template=complete&search=Romania&per_page=5

我们能否在上述页面上添加 meta noindex?或者更好的是,在上述页面上添加这个新的谷歌标签

5 个赞

谢谢你的建议@nader。我们应该默认将这个新标签添加到<iframe>中,@falco,还是将其设为一项设置?

4 个赞

这应该可以做到

6 个赞

我只是想指出,它正在向所有爬虫提供“noindex, indexifembedded”,尽管只有谷歌支持新的 indexifembedded”。

这可能应该更改为 x-robots-tag: googlebot:noindex, indexifembedded

或者完全删除,因为 noindex 可能对其他搜索引擎产生不可预见的后果。

1 个赞

我不认为多余的词对其他爬虫有特别大的危害。您有这方面的证据吗?例如,是否有其他爬虫告诉网站不要使用 indexifembedded

(大多数时候,编写此类代码时,您会忽略任何您不期望的 HTML 标签,这在 HTML 中是默认行为。)

3 个赞

我没看到,但在Google页面上确实提到:

目前,只有 Google 支持 indexifembedded 标签。

我同意他们会忽略 indexifembedded,但我担心的是 noindex 会对页面本身的 SEO 产生影响。

所以,我们让 Bing 爬取一个包含主题嵌入的 URL。它会爬取该 URL,同时也会爬取嵌入 URL:

/embed/topics?discourse_embed_id=XXXXXX....

如果上述 URL 被设置为 noindex,我担心这会损害展示主题嵌入的页面的 SEO。

所有这些都可以通过使用 x-robots-tag: googlebot:noindex, indexifembedded 来解决,但我可以理解为什么 Discourse 可能不想偏袒一个搜索引擎。希望它能成为标准,但目前看来,它似乎只适用于 Google。

3 个赞

您好!只是想问一下,是否仍然没有内置方法可以让嵌入式主题像 target="_blank" 一样打开,而不是 target="_parent"

3 个赞

只是好奇为什么我只能看到一个主题?有人知道吗?

这是类别(其中有许多主题):Amazon Specific - eCommerce Sellers Forum

这是嵌入代码:
<d-topics-list discourse-url="https://forum.flowster.app" template="complete" top_period="all" category="17" per-page="5"> </d-topics-list>

但只出现一个主题:

:thinking:

2 个赞