Add frontmatter and TOC rendering support for markdown files (#284)

<https://github.com/go-gitea/gitea/issues/14411#issuecomment-764871702>

Reviewed-on: https://gitea.com/gitea/docs/pulls/284
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: dangjinghao <dangjinghaoemail@163.com>
Co-committed-by: dangjinghao <dangjinghaoemail@163.com>
This commit is contained in:
dangjinghao
2025-10-23 17:55:14 +00:00
committed by Lunny Xiao
parent b6af199508
commit bb7b7fe5bf

View File

@@ -100,3 +100,26 @@ Using code-block with language:
\alpha
```
````
## Frontmatter
Gitea supports frontmatter and Table of Contents (TOC) rendering. By default, frontmatter rendering is enabled, and TOC rendering is disabled.
### Enabling TOC rendering
To enable TOC rendering for a markdown file, add `include_toc: true` to its frontmatter section.
### Disabling frontmatter
To disable frontmatter rendering for a markdown file, add `gitea: none` to its frontmatter section.
### Example
```yaml
---
include_toc: true
gitea: none
---
```
Then, when you preview this markdown file in Gitea, the frontmatter section will not be rendered, and a Table of Contents will be generated at the top of the content.