HUGO
Menu
GitHub 87548 stars Mastodon

FirstSection

返回给定页面为其后代的顶层栏目的 Page 对象。

Syntax

PAGE.FirstSection

Returns

page.Page

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

在主页上调用时,FirstSection 方法返回主页本身的 Page 对象。

考虑此内容结构:

content/
├── auctions/
│   ├── 2023-11/
│   │   ├── _index.md     <-- 第一栏目:auctions
│   │   ├── auction-1.md
│   │   └── auction-2.md  <-- 第一栏目:auctions
│   ├── 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="{{ .FirstSection.RelPermalink }}">{{ .FirstSection.LinkTitle }}</a>

Last updated: January 1, 0001
Improve this page