在 sphinx 文档中包含独立的 HTML 页面 [英] Include standalone HTML page in sphinx document
问题描述
对于我的大部分项目文档,我更喜欢标准的 sphinx 布局.但是,对于登录页面,我更喜欢使用自定义 HTML/CSS/JS,而不使用普通 sphinx 站点的任何布局、TOC 或侧边栏.有没有办法在 sphinx 生成的网站中包含原始 HTML 独立页面,完全不考虑网站其余部分的正常布局?
For most of my project's documentation I prefer a standard sphinx layout. However for the landing page I would prefer to use custom HTML/CSS/JS without any of the layout, TOC, or sidebars of the normal sphinx site. Is there a way to include a raw HTML standalone page in a sphinx-generated website in a way that completely disregards the normal layout of the rest of the site?
作为一个反例,我知道我可以使用以下内容将原始 HTML 位包含到页面中(另请参见 这个问题)
As a counter example I know that I can include raw HTML bits into a page using the following (see also this question)
.. raw:: html
:file: myfile-html
然而,这只是在正常布局中嵌入一个文件.我想要一个完全独立的 HTML 页面.
However this just embeds a file within the normal layout. I would like to have a completely standalone HTML page.
推荐答案
我自己刚刚遇到了这个问题,我解决它的方法是简单地将 html 文件包含在我的 source/_static
中文件夹,然后使用相对链接引用它.
I just ran into this problem myself, and the way I solved it was to simply include the html file in my source/_static
folder, then refer to it with a relative link.
因此,如果 source/_static/my_standalone.htm
是我的非生成 HTML 文件的路径,而我想输入链接的 .rst 文件位于 source/otherfolder/index.rst
,我在我的rst里是这样写的:
So if source/_static/my_standalone.htm
is the path where I have my non-generated HTML file, and the .rst file where I want to type my link is at source/otherfolder/index.rst
, I write it like this in my rst:
Link to my non-Sphinx HTML file
===============================
To get to my standalone, non-generated HTML file,
just `click here <../_static/my_standalone.html>`_ now!
这篇关于在 sphinx 文档中包含独立的 HTML 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!