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 4.4KB

6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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`, then it will generate a page
  8. with the name of the containing folder (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 the prior part of this documentation. But 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`). So naming a file in the root of your
  15. content directory `about.md` would also create a page at `[base_url]/about`.
  16. Another exception to that rule is that a filename starting with a datetime (YYYY-mm-dd or [a 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 a filename like `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 exactly equivalent to creating an
  22. `about/index.md` file. The only difference between the two methods is that creating
  23. the `about` folder allows you to use asset colocation, as discussed in the
  24. [Overview](@/documentation/content/overview.md#assets-colocation) section of this documentation.
  25. ## Front-matter
  26. The front-matter is a set of metadata embedded in a file. In Zola,
  27. it is at the beginning of the file, surrounded by `+++` and uses TOML.
  28. While none of the front-matter variables are mandatory, the opening and closing `+++` are required.
  29. Here is an example page with all the variables available. The values provided below are the default
  30. values.
  31. ```toml
  32. title = ""
  33. description = ""
  34. # The date of the post.
  35. # 2 formats are allowed: YYYY-MM-DD (2012-10-02) and RFC3339 (2002-10-02T15:00:00Z)
  36. # Do not wrap dates in quotes, the line below only indicates that there is no default date.
  37. # If the section variable `sort_by` is set to `date`, then any page that lacks a `date`
  38. # will not be rendered.
  39. # Setting this overrides a date set in the filename.
  40. date =
  41. # The weight as defined in the Section page
  42. # If the section variable `sort_by` is set to `weight`, then any page that lacks a `weight`
  43. # will not be rendered.
  44. weight = 0
  45. # A draft page is only loaded if the `--drafts` flag is passed to `zola build`, `zola serve` or `zola check`
  46. draft = false
  47. # If filled, it will use that slug instead of the filename to make up the URL
  48. # It will still use the section path though
  49. slug = ""
  50. # The path the content will appear at
  51. # If set, it cannot be an empty string and will override both `slug` and the filename.
  52. # The sections' path won't be used.
  53. # It should not start with a `/` and the slash will be removed if it does
  54. path = ""
  55. # Use aliases if you are moving content but want to redirect previous URLs to the
  56. # current one. This takes an array of path, not URLs.
  57. aliases = []
  58. # Whether the page should be in the search index. This is only used if
  59. # `build_search_index` is set to true in the config and the parent section
  60. # hasn't set `in_search_index` to false in its front-matter
  61. in_search_index = true
  62. # Template to use to render this page
  63. template = "page.html"
  64. # The taxonomies for that page. The keys need to be the same as the taxonomies
  65. # name configured in `config.toml` and the values an array of String like
  66. # tags = ["rust", "web"]
  67. [taxonomies]
  68. # Your own data
  69. [extra]
  70. ```
  71. ## Summary
  72. You can ask Zola to create a summary if you only want to show the first
  73. paragraph of each page in a list for example.
  74. To do so, add <code>&lt;!-- more --&gt;</code> in your content at the point
  75. where you want the summary to end and the content up to that point will be also
  76. available separately in the
  77. [template](@/documentation/templates/pages-sections.md#page-variables).
  78. An anchor link to this position named `continue-reading` is created, wrapped in a paragraph
  79. with a `zola-continue-reading` id, so you can link directly to it if needed for example:
  80. `<a href="{{ page.permalink }}#continue-reading">Continue Reading</a>`