# 什么使网站与onebox预览兼容？

**URL:** https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949
**Category:** Support
**Created:** [2021年五月19日 18:17 UTC](https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949 "2021-05-19T18:17:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Wall-E](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wall-e/32/184438_2.png) [@Wall-E](https://meta.discourse.org/u/Wall-E)
#### Post date: [2021年五月19日 18:17 UTC](https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949/1 "2021-05-19T18:17:10Z")

</div>

我想帮助以下 Python 框架的开发人员，使其与我们的 Discourse 实例的 onebox 功能兼容，从而推广该框架：

[https://docs.sunpy.org/en/v3.0.0/whatsnew/3.0.html](https://docs.sunpy.org/en/v3.0.0/whatsnew/3.0.html)

那么，什么样的网站才能与 onebox 兼容呢？我在谷歌上搜索了 onebox，并找到了这个 GitHub 页面：[https://github.com/discourse/onebox。不过，对于我所提到的框架，他们使用](https://github.com/discourse/onebox%E3%80%82%E4%B8%8D%E8%BF%87%EF%BC%8C%E5%AF%B9%E4%BA%8E%E6%88%91%E6%89%80%E6%8F%90%E5%88%B0%E7%9A%84%E6%A1%86%E6%9E%B6%EF%BC%8C%E4%BB%96%E4%BB%AC%E4%BD%BF%E7%94%A8) [Sphinx](https://www.sphinx-doc.org/en/master/) 来自动生成部分页面。因此，开发人员是否可以通过设置某些 Sphinx 选项，使其页面与 onebox 兼容？

---

<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: [2021年五月19日 18:41 UTC](https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949/2 "2021-05-19T18:41:51Z")

</div>

如果你在一行中单独尝试链接 `https://docs.sunpy.org/en/v3.0.0/whatsnew/3.0.html`，你将看到以下消息：

> 抱歉，我们无法为该网页生成预览，因为找不到以下 oEmbed / OpenGraph 标签：description、image

该页面的 `description` OpenGraph 元标签为空，因此我们无法嵌入它。此外，它还为其他一些 OpenGraph 标签（如 `image` 和 `url`）使用了相对 URL，我不确定这是否受支持。

---

<div class="post-metadata">

### Author: ![Wall-E](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wall-e/32/184438_2.png) [@Wall-E](https://meta.discourse.org/u/Wall-E)
#### Post date: [2021年五月26日 23:25 UTC](https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949/3 "2021-05-26T23:25:32Z")

</div>

所以我已将相关信息转发给 SunPy 开发团队。他们针对此页面测试了一个修复方案：[https://sunpy--5366.org.readthedocs.build/en/5366/。opengraph.xyz](https://sunpy--5366.org.readthedocs.build/en/5366/%E3%80%82opengraph.xyz) 验证结果显示，所有标签均已在 HTML 文件中定义：

```plaintext
<!-- HTML Meta Tags -->
<title>SunPy Documentation</title>
<meta name="description" content="SunPy Documentation">

<!-- Facebook Meta Tags -->
<meta property="og:description" content="SunPy Documentation">
<meta property="og:image" content="https://raw.githubusercontent.com/sunpy/sunpy-logo/master/generated/sunpy_logo_word.png" />
<meta property="og:site_name" content="SunPy Documentation" />
<meta property="og:title" content="SunPy Documentation">
<meta property="og:type" content="website">
<meta property="og:url" content="https://docs.sunpy.org/en/stable//index.html" />

<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="SunPy Documentation">
<meta name="twitter:image" content="https://raw.githubusercontent.com/sunpy/sunpy-logo/master/generated/sunpy_logo_word.png">
<meta name="twitter:title" content="SunPy Documentation">
<meta property="twitter:domain" content="https://docs.sunpy.org/en/stable/">
<meta property="twitter:url" content="https://docs.sunpy.org/en/stable//index.html">

```

尽管如此，在我们的 Discourse 实例中仍然无法正常工作，依旧报错：`oEmbed / OpenGraph tags could not be found:description, image`

他们是否遗漏了什么？这是我们关于此问题的 GitHub 讨论线程：[onebox-compatible documentation for promoting SunPy's features and updates · Issue #5362 · sunpy/sunpy · GitHub](https://github.com/sunpy/sunpy/issues/5362)

---

<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: [2021年五月26日 23:28 UTC](https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949/4 "2021-05-26T23:28:29Z")

</div>

这真的是一个有效的条目吗？描述应该更长，并包含页面实际内容的一部分，而不是像“SunPy 文档”这样的占位符。

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2021年五月27日 01:32 UTC](https://meta.discourse.org/t/what-makes-a-site-compatible-with-onebox-previews/190949/5 "2021-05-27T01:32:03Z")

</div>

描述被忽略了，因为它与标题完全相同。您应该从内容中提取相关部分填入描述属性。
