HUGO
Menu
GitHub 87548 stars Mastodon

CurrentSection

返回给定页面所在栏目的 Page 对象。

Syntax

PAGE.CurrentSection

Returns

page.Page

section(节)是顶级内容目录或任何包?_index.md 文件的内容目录

栏目页面分类法页面术语页面 或主页的当前栏目是其自身。

考虑此内容结构:

content/
├── auctions/
│   ├── 2023-11/
│   │   ├── _index.md     <-- 当前栏目:2023-11
│   │   ├── auction-1.md
│   │   └── auction-2.md  <-- 当前栏目:2023-11
│   ├── 2023-12/
│   │   ├── _index.md     
│   │   ├── auction-3.md
│   │   └── auction-4.md
│   ├── _index.md         <-- 当前栏目:auctions
│   ├── bidding.md
│   └── payment.md        <-- 当前栏目:auctions
├── books/
│   ├── _index.md         <-- 当前栏目:books
│   ├── book-1.md
│   └── book-2.md         <-- 当前栏目:books
├── films/
│   ├── _index.md         <-- 当前栏目:films 
│   ├── film-1.md
│   └── film-2.md         <-- 当前栏目:films
└── _index.md             <-- 当前栏目:home

创建指向当前栏目页面的链接:

<a href="{{ .CurrentSection.RelPermalink }}">{{ .CurrentSection.LinkTitle }}</a>

Last updated: January 1, 0001
Improve this page