You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

page.md 6.8KB

6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. +++
  2. title = "Page"
  3. weight = 30
  4. +++
  5. A page is any file ending with `.md` in the `content` directory, except files
  6. named `_index.md`.
  7. If a file ending with `.md` is named `index.md`, it will generate a page
  8. with the name of its directory (for example, `/content/about/index.md` would
  9. create a page at `[base_url]/about`). (Note the lack of an underscore; if the file
  10. were named `_index.md`, then it would create a **section** at `[base_url]/about`, as
  11. discussed in a previous part of this documentation. In contrast, naming the file `index.md` will
  12. create a **page** at `[base_url]/about`).
  13. If the file is given any name *other* than `index.md` or `_index.md`, then it will
  14. create a page with that name (without the `.md`). For example, naming a file in the root of your
  15. content directory `about.md` would create a page at `[base_url]/about`.
  16. Another exception to this rule is that a filename starting with a datetime (YYYY-mm-dd or [an RFC3339 datetime](https://www.ietf.org/rfc/rfc3339.txt)) followed by
  17. an underscore (`_`) or a dash (`-`) will use that date as the page date, unless already set
  18. in the front matter. The page name will be anything after `_`/`-`, so the file `2018-10-10-hello-world.md` will
  19. be available at `[base_url]/hello-world`. Note that the full RFC3339 datetime contains colons, which is not a valid
  20. character in a filename on Windows.
  21. As you can see, creating an `about.md` file is equivalent to creating an
  22. `about/index.md` file. The only difference between the two methods is that creating
  23. the `about` directory allows you to use asset co-location, as discussed in the
  24. [overview](@/documentation/content/overview.md#asset-colocation) section.
  25. ## Output paths
  26. For any page within your content folder, its output path will be defined by either:
  27. - its `slug` frontmatter key
  28. - its filename
  29. Either way, these proposed path will be sanitized before being used.
  30. If `slugify_paths` is enabled in the site's config - the default - paths are [slugified](https://en.wikipedia.org/wiki/Clean_URL#Slug).
  31. Otherwise, a simpler sanitation is performed, outputting only valid NTFS paths.
  32. The following characters are removed: `<`, `>`, `:`, `/`, `|`, `?`, `*`, `#`, `\\`, `(`, `)`, `[`, `]` as well as newlines and tabulations.
  33. Additionally, trailing whitespace and dots are removed and whitespaces are replaced by `_`.
  34. **NOTE:** To produce URLs containing non-English characters (UTF8), `slugify_paths` needs to be set to `false`.
  35. ### Path from frontmatter
  36. The output path for the page will first be read from the `slug` key in the page's frontmatter.
  37. **Example:** (file `content/zines/mlf-kurdistan.md`)
  38. ```
  39. +++
  40. title = "Le mouvement des Femmes Libres, à la tête de la libération kurde"
  41. slug = "femmes-libres-libération-kurde"
  42. +++
  43. This is my article.
  44. ```
  45. This frontmatter will output the article to `[base_url]/zines/femmes-libres-libération-kurde` with `slugify_paths` disabled, and to `[base_url]/zines/femmes-libres-liberation-kurde` with `slugify_enabled` enabled.
  46. ### Path from filename
  47. When the article's output path is not specified in the frontmatter, it is extracted from the file's path in the content folder. Consider a file `content/foo/bar/thing.md`. The output path is constructed:
  48. - if the filename is `index.md`, its parent folder name (`bar`) is used as output path
  49. - otherwise, the output path is extracted from `thing` (the filename without the `.md` extension)
  50. If the path found starts with a datetime string (`YYYY-mm-dd` or [a RFC3339 datetime](https://www.ietf.org/rfc/rfc3339.txt)) followed by an underscore (`_`) or a dash (`-`), this date is removed from the output path and will be used as the page date (unless already set in the front-matter). Note that the full RFC3339 datetime contains colons, which is not a valid character in a filename on Windows.
  51. The output path extracted from the file path is then slugified or not depending on the `slugify_paths` config, as explained previously.
  52. **Example:** The file `content/blog/2018-10-10-hello-world.md` will generated a page available at will be available at `[base_url]/hello-world`.
  53. ## Front matter
  54. The TOML front matter is a set of metadata embedded in a file at the beginning of the file enclosed
  55. by triple pluses (`+++`).
  56. Although none of the front matter variables are mandatory, the opening and closing `+++` are required.
  57. Here is an example page with all the available variables. The values provided below are the
  58. default values.
  59. ```toml
  60. title = ""
  61. description = ""
  62. # The date of the post.
  63. # Two formats are allowed: YYYY-MM-DD (2012-10-02) and RFC3339 (2002-10-02T15:00:00Z).
  64. # Do not wrap dates in quotes; the line below only indicates that there is no default date.
  65. # If the section variable `sort_by` is set to `date`, then any page that lacks a `date`
  66. # will not be rendered.
  67. # Setting this overrides a date set in the filename.
  68. date =
  69. # The weight as defined on the Section page of the documentation.
  70. # If the section variable `sort_by` is set to `weight`, then any page that lacks a `weight`
  71. # will not be rendered.
  72. weight = 0
  73. # A draft page is only loaded if the `--drafts` flag is passed to `zola build`, `zola serve` or `zola check`.
  74. draft = false
  75. # If set, this slug will be instead of the filename to make the URL.
  76. # The section path will still be used.
  77. slug = ""
  78. # The path the content will appear at.
  79. # If set, it cannot be an empty string and will override both `slug` and the filename.
  80. # The sections' path won't be used.
  81. # It should not start with a `/` and the slash will be removed if it does.
  82. path = ""
  83. # Use aliases if you are moving content but want to redirect previous URLs to the
  84. # current one. This takes an array of paths, not URLs.
  85. aliases = []
  86. # When set to "true", the page will be in the search index. This is only used if
  87. # `build_search_index` is set to "true" in the Zola configuration and the parent section
  88. # hasn't set `in_search_index` to "false" in its front matter.
  89. in_search_index = true
  90. # Template to use to render this page.
  91. template = "page.html"
  92. # The taxonomies for this page. The keys need to be the same as the taxonomy
  93. # names configured in `config.toml` and the values are an array of String objects. For example,
  94. # tags = ["rust", "web"].
  95. [taxonomies]
  96. # Your own data.
  97. [extra]
  98. ```
  99. ## Summary
  100. You can ask Zola to create a summary if, for example, you only want to show the first
  101. paragraph of the page content in a list.
  102. To do so, add <code>&lt;!-- more --&gt;</code> in your content at the point
  103. where you want the summary to end. The content up to that point will be
  104. available separately in the
  105. [template](@/documentation/templates/pages-sections.md#page-variables).
  106. An anchor link to this position named `continue-reading` is created, wrapped in a paragraph
  107. with a `zola-continue-reading` id, so you can link directly to it if needed. For example:
  108. `<a href="{{ page.permalink }}#continue-reading">Continue Reading</a>`.