# 在另一个网站中嵌入 Discourse 主题列表

**URL:** <https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911>\
**Category:** Announcements\
**Tags:** embedding\
**Created:** [2019年八月15日 17:53 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911 "2019-08-15T17:53:02Z")\
**Posts on this page:** 12\
**Page:** 5

<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:** [2022年五月20日 20:09 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/136 "2022-05-20T20:09:24Z")

</div>

> [@Kane\_Thomas](#):
>
> 只是好奇为什么我只能看到 1 个主题？有人知道吗？

我看到了所有请求的主题：[https://forum.flowster.app/embed/topics?discourse\_embed\_id=de-k0ofgk7q0&category=17&per\_page=5&template=complete&top\_period=all](https://forum.flowster.app/embed/topics?discourse_embed_id=de-k0ofgk7q0&category=17&per_page=5&template=complete&top_period=all)

也许 iframe 所在的 div 太小了，以至于您看不到其他主题？

---

<div class="post-metadata">

**Author:** ![Kane\_Thomas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kane_thomas/32/137561_2.png) [@Kane\_Thomas](https://meta.discourse.org/u/Kane_Thomas)\
**Post date:** [2022年五月20日 22:34 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/137 "2022-05-20T22:34:52Z")

</div>

@Falco 感谢您的帮助！使用该链接，我看到了多个主题，但是这段 HTML 代码为什么不起作用？是不是我在 `\u003cd-topics-list\u003e` 标签上做错了什么？

```plaintext
<!DOCTYPE html>
<html lang="en">
  <head>
	<script src="https://forum.flowster.app/javascripts/embed-topics.js"></script>
</head>
<body>
	<d-topics-list discourse-url="https://forum.flowster.app" template="complete" top_period="all" category="17" per-page="5"></d-topics-list>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![Kane\_Thomas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kane_thomas/32/137561_2.png) [@Kane\_Thomas](https://meta.discourse.org/u/Kane_Thomas)\
**Post date:** [2022年六月26日 20:45 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/138 "2022-06-26T20:45:11Z")

</div>

有人知道答案吗？我上面的 HTML 代码为什么不起作用？ 😢

---

<div class="post-metadata">

**Author:** ![stance455](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stance455/32/255345_2.png) [@stance455](https://meta.discourse.org/u/stance455)\
**Post date:** [2022年七月7日 19:38 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/139 "2022-07-07T19:38:08Z")

</div>

当 Google 呈现使用 Discourse 主题嵌入功能的页面时，它似乎使用了大写的 `<div>` 元素。

下面是 Google 搜索控制台中渲染的 HTML 屏幕截图。

 ![Screen Shot 2022-07-07 at 10.37.16 PM](https://global.discourse-cdn.com/meta/original/4X/d/0/f/d0f65dbc06355ff12fd155609d1f80be7064c98d.jpeg)

---

<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:** [2022年九月12日 18:48 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/145 "2022-09-12T18:48:27Z")

</div>

嵌入式主题列表的一个问题是，当点击嵌入式主题列表条目时，用户总是会被带到主题的第一篇帖子。我们通过支持系统收到一个请求，询问是否有什么方法可以让用户被带到主题的“最后”一篇帖子，而不是第一篇。

如果这对其他网站也有用，是否可以在嵌入代码中添加一个“last”参数，以便用户能够自动被带到主题的最后一篇帖子，而不是第一篇？

我意识到这与讨论应该从头到尾阅读的理念相悖，但由于无法在嵌入主题列表的网站上存储用户上次阅读的帖子，因此在这种情况下，允许网站将用户指向主题的最后一篇帖子可能是合理的。

---

<div class="post-metadata">

**Author:** ![stance455](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stance455/32/255345_2.png) [@stance455](https://meta.discourse.org/u/stance455)\
**Post date:** [2022年十月4日 20:22 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/146 "2022-10-04T20:22:29Z")

</div>

我想再次提出这个问题，因为它对页面来说是一个严重的 SEO 问题。

使用嵌入式主题创建的 URL 的标头具有 x-robots-tag: noindex,indexifembedded

indexifembedded 仅适用于 Google

它应该更像 `X-Robots-Tag: googlebot:noindex,indexifembedded`

或者也许完全删除该标签。

真正的负面影响是，必应或任何其他爬虫将不会索引或考虑由嵌入式主题显示的内​​容。（因为它只识别 `noindex` 部分）

[示例网址](https://discuss.flynumber.com/embed/topics?discourse_embed_id=de-d49rj6kge&template=complete&allow_create=true&search=Australia&per_page=5)

---

<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:** [2022年十月5日 14:16 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/147 "2022-10-05T14:16:22Z")

</div>

> [@stance455](#):
>
> 真正的负面影响是，必应或任何其他爬虫都不会索引或考虑嵌入主题所显示的内容。（因为它只抓取 `noindex` 部分）

这正是我们想要的，对吧？我不想让任何爬虫直接索引 `/embed/topics` 下的任何内容。

---

<div class="post-metadata">

**Author:** ![stance455](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stance455/32/255345_2.png) [@stance455](https://meta.discourse.org/u/stance455)\
**Post date:** [2022年十月5日 16:25 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/148 "2022-10-05T16:25:42Z")

</div>

你好 @Falco

我不这么认为，因为那意味着我的示例网址不会被索引。

[https://discuss.flynumber.com/embed/topics?discourse\_embed\_id=de-d49rj6kge&template=complete&allow\_create=true&search=Australia&per\_page=5](https://discuss.flynumber.com/embed/topics?discourse_embed_id=de-d49rj6kge&template=complete&allow_create=true&search=Australia&per_page=5)

Google 会将这些网址作为单独的网址抓取，与嵌入主题显示的网址不同。

它仍然会抓取我的网址

[https://www.flynumber.com/products/virtual-phone-number/australia](https://www.flynumber.com/products/virtual-phone-number/australia)

但是 Bing 会访问 embed/topics 网址，看到非索引内容，并且不会将其计入上述网址。

虽然 Google 不会索引 embed/topics 网址，但由于它理解“indexifembedded”，因此它仍然会将内容计入显示嵌入的页面。

---

<div class="post-metadata">

**Author:** ![Brandon007](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@Brandon007](https://meta.discourse.org/u/Brandon007)\
**Post date:** [2023年八月19日 15:05 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/155 "2023-08-19T15:05:12Z")

</div>

使用此功能后，我有一些反馈……

最好能包含多个 `category` 而不仅仅是一个。我不得不进行一些调整才能不显示某些帖子。使用 `exclude_tag` 可以实现这一点。

但是，我创建了一个 `admin` 标签，并将其添加到我不想在嵌入式内容中显示的帖子上。当我尝试将我的 `admin` `tag` 的设置更改为“标签仅对以下组可见”时，它会移除 `exclude_tag` 的功能。

我希望隐藏我论坛上的标签，同时仍将该标签从嵌入式内容中排除。

---

<div class="post-metadata">

**Author:** ![samarth.tholia](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@samarth.tholia](https://meta.discourse.org/u/samarth.tholia)\
**Post date:** [2023年十一月6日 09:20 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/156 "2023-11-06T09:20:21Z")

</div>

有人尝试过将 Discourse 嵌入 Salesforce 页面，使用 LWC 说社区吗？我不认为 `<d-topics-list>` 会在那里被识别。

---

<div class="post-metadata">

**Author:** ![stance455](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stance455/32/255345_2.png) [@stance455](https://meta.discourse.org/u/stance455)\
**Post date:** [2023年十一月8日 14:09 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/158 "2023-11-08T14:09:28Z")

</div>

世界末日倒计时，但搜索参数不包含附加到主题的标签。

例如，我有这个

```plaintext
<div class="rss-widget">
<h2 style="text-align: center;">与美国相关的论坛主题</h2>
<hr>

<script defer src="https://discuss.example.com/javascripts/embed-topics.js"></script>

<d-topics-list discourse-url="https://discuss.example.com" template="complete" search="usa" per-page="7"></d-topics-list>
</div>

```

它不会显示带有“usa”标签的主题，如果类型“usa”到帖子正文中，它就会显示出来。

---

<div class="post-metadata">

**Author:** ![ootwch](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ootwch/32/141093_2.png) [@ootwch](https://meta.discourse.org/u/ootwch)\
**Post date:** [2024年二月25日 11:26 UTC](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911/159 "2024-02-25T11:26:36Z")

</div>

您好！  
是否可以显示嵌入列表中的主题（或类别）的标签？或者添加主页上可用的 CSS 类，以便我们可以设置主题的样式？

我想我正在寻找的是能够使嵌入式主题列表看起来与主页上的主题列表完全一样……例如这个：[Topics tagged official](https://meta.discourse.org/tag/official) ……

[上一頁](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911.md?page=4)
