Mkdocs 超链接在静态页面中不起作用
Mkdocs hyperlink not working in static pages
我正在尝试使用 mkdocs 构建文档。
问题是静态创建页面中的链接不起作用。
我没有转到 [folder]/index.html,而是看到了如下页面 image
但是当我尝试 mkdocs serve 时问题不存在
在您的 mkdocs.yml
配置文件中将 use_directory_urls 设置为 false
:
use_directory_urls: false
文档解释:
This setting controls the style used for linking to pages within the
documentation.
The following table demonstrates how the URLs used on the site differ
when setting use_directory_urls
to true
or false
.
Source file | Generated HTML | use_directory_urls: true | use_directory_urls: false
------------ | -------------------- | ------------------------ | ------------------------
index.md | index.html | / | /index.html
api-guide.md | api-guide/index.html | /api-guide/ | /api-guide/index.html
about.md | about/index.html | /about/ | /about/index.html
The default style of use_directory_urls: true
creates more user
friendly URLs, and is usually what you'll want to use.
The alternate style can occasionally be useful if you want your
documentation to remain properly linked when opening pages directly
from the file system, because it create links that point directly to
the target file rather than the target
directory.
最后一段是为什么这会产生影响的关键。
我正在尝试使用 mkdocs 构建文档。 问题是静态创建页面中的链接不起作用。 我没有转到 [folder]/index.html,而是看到了如下页面 image
但是当我尝试 mkdocs serve 时问题不存在
在您的 mkdocs.yml
配置文件中将 use_directory_urls 设置为 false
:
use_directory_urls: false
文档解释:
This setting controls the style used for linking to pages within the documentation.
The following table demonstrates how the URLs used on the site differ when setting
use_directory_urls
totrue
orfalse
.Source file | Generated HTML | use_directory_urls: true | use_directory_urls: false ------------ | -------------------- | ------------------------ | ------------------------ index.md | index.html | / | /index.html api-guide.md | api-guide/index.html | /api-guide/ | /api-guide/index.html about.md | about/index.html | /about/ | /about/index.html
The default style of
use_directory_urls: true
creates more user friendly URLs, and is usually what you'll want to use.The alternate style can occasionally be useful if you want your documentation to remain properly linked when opening pages directly from the file system, because it create links that point directly to the target file rather than the target directory.
最后一段是为什么这会产生影响的关键。