页是目录.md中以 结尾的任何文件content,但名为_index.md. 注意:页面文件名不能_index. 包含.

如果以 结尾的文件.md名为index.md,它将生成一个具有其目录名称的页面(例如,/content/about/index.md将在 处创建一个页面[base_url]/about)。(请注意缺少下划线;如果文件名为_index.md,那么它会在 处创建一个部分[base_url]/about,如本文档前面部分所讨论的那样。相反,命名文件将在 处index.md创建一个页面[base_url]/about)。

如果文件被赋予除之外任何名称,那么它将创建一个具有该名称(不带)的页面。例如,在您的内容目录的根目录中命名一个文件将在.index.md_index.md.mdabout.md[base_url]/about

此规则的另一个例外是以日期时间(YYYY-mm-dd 或RFC3339 日期时间)开头后跟下划线 ( _) 或破折号 ( )的文件名将-使用该日期作为页面日期,除非已在前面设置事情。页面名称将是_/之后的任何内容-,因此该文件2018-10-10-hello-world.md将在[base_url]/hello-world. 请注意,完整的 RFC3339 日期时间包含冒号,这在 Windows 上不是文件名中的有效字符。slugify.paths_keep_date可以通过设置为true(默认为)来禁用此行为false请注意,_分隔日期的 a 将被 slugified 为-默认值为slugify.pathsof的 a "on"

如您所见,创建about.md文件等同于创建 about/index.md文件。这两种方法之间的唯一区别是创建about目录允许您使用资产共置,如 概述部分所述。

🔗输出路径

对于内容文件夹中的任何页面,其输出路径将定义为:

  • 它的slug前键
  • 它的文件名

无论哪种方式,这些建议的路径都将在使用前进行清理。如果在站点的配置中slugify.paths设置为- 默认 - 路径是slugified如果设置为,仅执行清理,并删除以下字符:, , , , , , , , , , , ,以及换行符和制表符。这确保路径可以在所有操作系统上表示。此外,尾随的空格和点被删除,空格被替换为."on""safe"<>:/|?*#\\()[]_

如果slugify.paths设置为"off",则不进行任何修改。

如果您想要包含非 ASCII 字符的 URL,slugify.paths需要设置为"safe""off"

🔗来自 frontmatter 的路径

slug页面的输出路径将首先从页面的 frontmatter 中的键中读取。

示例:(文件content/zines/mlf-kurdistan.md

+++
title = "Le mouvement des Femmes Libres, à la tête de la libération kurde"
slug = "femmes-libres-libération-kurde"
+++
This is my article.

此 frontmatter 会将文章输出到设置为[base_url]/zines/femmes-libres-libération-kurdeorto并设置为of的默认值slugify.paths"safe""off"[base_url]/zines/femmes-libres-liberation-kurdeslugify.paths"on"

🔗来自文件名的路径

当文章的输出路径没有在 frontmatter 中指定时,它是从 content 文件夹中的文件路径中提取的。考虑一个文件content/foo/bar/thing.md构建输出路径:

  • 如果文件名为index.md,则其父文件夹名称 ( bar) 用作输出路径
  • 否则,输出路径是从thing (不带扩展名的文件名.md)中提取的

如果找到的路径以日期时间字符串(YYYY-mm-ddRFC3339 日期时间)开头,后跟可选的空格,然后是下划线 ( _) 或破折号 ( -),则此日期将从输出路径中删除并将用作页面日期(除非已经设置在最前面)。请注意,完整的 RFC3339 日期时间包含冒号,这在 Windows 上不是文件名中的有效字符。

slugify.paths如前所述,根据配置,从文件路径中提取的输出路径是否被 slugified 。

示例: 该文件content/blog/2018-10-10-hello-world.md将在 产生一个页面[base_url]/blog/hello-world使用可选的空格,文件content/blog/2021-01-23 -hello new world.md将产生一个页面[base_url]/blog/hello-new-world

🔗前言

TOML front matter 是一组嵌入文件中的元数据,位于文件的开头,由三重加号 ( +++) 括起来。

尽管前面的变量都不是强制性的,但打开和关闭+++是必需的。

请注意,尽管鼓励使用 TOML,但也支持 YAML front matter 以简化遗留内容的移植。在这种情况下,嵌入的元数据必须包含在三重负数 ( ---) 中。

这是一个包含所有可用变量的示例页面。下面提供的值是默认值。

title = ""
description = ""

# The date of the post.
# Two formats are allowed: YYYY-MM-DD (2012-10-02) and RFC3339 (2002-10-02T15:00:00Z).
# Do not wrap dates in quotes; the line below only indicates that there is no default date.
# If the section variable `sort_by` is set to `date`, then any page that lacks a `date`
# will not be rendered.
# Setting this overrides a date set in the filename.
date =

# The last updated date of the post, if different from the date.
# Same format as `date`.
updated =

# The weight as defined on the Section page of the documentation.
# If the section variable `sort_by` is set to `weight`, then any page that lacks a `weight`
# will not be rendered.
weight = 0

# A draft page is only loaded if the `--drafts` flag is passed to `zola build`, `zola serve` or `zola check`.
draft = false

# If set, this slug will be used instead of the filename to make the URL.
# The section path will still be used.
slug = ""

# The path the content will appear at.
# If set, it cannot be an empty string and will override both `slug` and the filename.
# The sections' path won't be used.
# It should not start with a `/` and the slash will be removed if it does.
path = ""

# Use aliases if you are moving content but want to redirect previous URLs to the
# current one. This takes an array of paths, not URLs.
aliases = []

# A list of page authors. If a site feed is enabled, the first author (if any)
# will be used as the page's author in the default feed template.
authors = []

# When set to "true", the page will be in the search index. This is only used if
# `build_search_index` is set to "true" in the Zola configuration and the parent section
# hasn't set `in_search_index` to "false" in its front matter.
in_search_index = true

# Template to use to render this page.
template = "page.html"

# The taxonomies for this page. The keys need to be the same as the taxonomy
# names configured in `config.toml` and the values are an array of String objects. For example,
# tags = ["rust", "web"].
[taxonomies]

# Your own data.
[extra]

🔗总结

例如,如果您只想在列表中显示页面内容的第一段,您可以要求 Zola 创建摘要。

为此,请<!-- more -->在您希望摘要结束的位置添加您的内容。到那时为止的内容将 通过单独在模板page.summary中提供。

continue-reading在此位置创建一个带有 id 的 span 元素,因此如果需要,您可以直接链接到它。例如: <a href="{{ page.permalink }}#continue-reading">Continue Reading</a>