You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Sphinx中index.rst混合include指令与rst文件引用失效问题

Fixing the Broken Include/Page Reference in Sphinx index.rst

Hey there, I see exactly what's going wrong here! The issue comes from mixing up how the .. include:: directive works and how to add additional pages to your Sphinx documentation. Let's break this down and fix it.

Why Your Current Setup Fails

The .. include:: directive is designed to pull the content of one specific file into the current document. When you added static and about right after .. include:: list.rst, you're invalidating the syntax—Sphinx doesn't recognize those extra filenames as part of the include directive, and they aren't valid standalone RST commands either. That's why your setup broke.

Solution 1: Include Multiple Files Directly in index.rst

If you want the content of static.rst and about.rst to be embedded directly into the index.rst page (so all content lives on one page), you need to use a separate .. include:: directive for each file:

Project Test 
============================

.. include:: list.rst
.. include:: static.rst
.. include:: about.rst

This will pull the content of all three files into your index page in the order you list them.

Solution 2: Add static and about as Separate Pages (Using toctree)

If you want static and about to be distinct pages in your documentation (with their own entries in the navigation menu), you should use Sphinx's toctree directive instead of trying to list them after the include. Here's how to set that up:

Project Test 
============================

.. include:: list.rst

.. toctree::
   :maxdepth: 2
   :caption: Additional Pages

   static
   about

This will:

  1. Keep the content of list.rst embedded in your index page.
  2. Add static.rst and about.rst as separate pages under the "Additional Pages" section in your documentation's navigation.

Make sure that static.rst and about.rst exist in the same directory as index.rst (or adjust the paths accordingly if they're in subfolders).

Pick the solution that matches what you're trying to achieve—either embedding all content into one page, or creating separate navigable pages.

内容的提问来源于stack exchange,提问作者nyi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:14:18