【问题标题】:How to control image previews for links to readthedocs/ sphinx page?如何控制 readthedocs/sphinx 页面链接的图像预览?
【发布时间】:2021-01-28 18:58:48
【问题描述】:

我是否可以在conf.py 中调整设置以确保为指向我的 index.html 的链接生成图像预览?

我想我需要在里面放一个图片的链接:

<head><meta name="og:image" content="https://.png" /></head>

也许是html_* 选项之一的设置?我通读了它们,但什么也没看到。

https://www.sphinx-doc.org/en/master/usage/configuration.html

链接到的页面:https://aiqc.readthedocs.io/en/latest/

【问题讨论】:

  • 这完全取决于您选择的 Sphinx 主题。请查看其文档以查看是否支持此功能。 AFAIK,开箱即用的 Sphinx 没有这样的功能。您或许可以modify a theme 支持图片链接预览。
  • RTD 主题不支持此功能。您必须自定义 RTD 主题,或提交添加此功能的拉取请求。欢迎使用开源软件,其中不存在的功能是由实际使用它们的人创建的。
  • @StevePiercy 看起来我又活了一天

标签: python-sphinx restructuredtext read-the-docs


【解决方案1】:

许多元标记之一:

https://github.com/wpilibsuite/sphinxext-opengraph

conf.py

extensions = ['sphinxext.opengraph']

ogp_image = "https://raw.githubusercontent.com/aiqc/aiqc/main/docs/images/aiqc_logo_banner_controlroom.png"

它甚至还有一个用户定义的&lt;meta&gt;标签字段。

【讨论】:

    猜你喜欢
    • 2015-11-27
    • 2013-07-27
    • 2014-06-08
    • 2016-06-05
    • 2023-03-30
    • 1970-01-01
    • 2017-03-26
    • 1970-01-01
    • 2018-02-09
    相关资源
    最近更新 更多