Mkdocs material 对指定页面隐藏 H1 标题 #53
shenweiyan
announced in
2.2-好玩
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
主要记录一下在 Mkdocs material 中对指定页面隐藏标题,尤其是指在 Home 页面把 H1 级别的标题隐藏的一些解决方法。
背景
对于一些特定的页面,不想显示顶级的标题,尤其是 H1 标题。Mkdocs material 讨论区给出了几个方案:
这个方法的确能解决隐藏当前页面的 H1 标题,但同时会把搜索栏搜索结果的 H1 标题给隐藏了。有点治标不治本!
这个参考的讨论里面没有给出具体的解决方法,本文章来详细介绍一下。
创建模板
首先,在
overrides
目录下创建一个名为home.html
的文件(文件名可以随意命名),内容可以参考blog.html
的内容。第二,创建
overrides/partials/mycontent.html
文件,内容参考content.html
文件,注意把 h1 的元素注释掉。在页面中使用模板
例如,在个人站点的主页文件
docs/index.md
中头部,使用template
指定使用的模板。最后,重新启动 mkdocs 就可以看到对应页面 H1 隐藏后的效果。
Beta Was this translation helpful? Give feedback.
All reactions