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.

overview.md 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. +++
  2. title = "Overview"
  3. weight = 10
  4. +++
  5. Zola uses the directory structure to determine the site structure.
  6. Each child directory in the `content` directory represents a [section](@/documentation/content/section.md)
  7. that contains [pages](@/documentation/content/page.md) (your `.md` files).
  8. ```bash
  9. .
  10. └── content
  11. ├── content
  12. │   └── something.md // -> https://mywebsite.com/content/something/
  13. ├── blog
  14. │   ├── cli-usage.md // -> https://mywebsite.com/blog/cli-usage/
  15. │   ├── configuration.md // -> https://mywebsite.com/blog/configuration/
  16. │   ├── directory-structure.md // -> https://mywebsite.com/blog/directory-structure/
  17. │   ├── _index.md // -> https://mywebsite.com/blog/
  18. │   └── installation.md // -> https://mywebsite.com/blog/installation/
  19. └── landing
  20. └── _index.md // -> https://mywebsite.com/landing/
  21. ```
  22. Each page path (the part after `base_url`, for example `blog/cli-usage/`) can be customised by changing the `path` or
  23. `slug` attribute of the [page front-matter](@/documentation/content/page.md#front-matter).
  24. You might have noticed a file named `_index.md` in the example above.
  25. This file is used to store both the metadata and content of the section itself and is not considered a page.
  26. To ensure that the terminology used in the rest of the documentation is understood, let's go over the example above.
  27. The `content` directory in this case has three `sections`: `content`, `blog` and `landing`. The `content` section has only
  28. one page (`something.md`), the `landing` section has no pages and the `blog` section has 4 pages (`cli-usage.md`,
  29. `configuration.md`, `directory-structure.md` and `installation.md`).
  30. Sections can be nested indefinitely.
  31. ## Asset colocation
  32. The `content` directory is not limited to markup files. It's natural to want to co-locate a page and some related
  33. assets, such as images or spreadsheets. Zola supports this pattern out of the box for both sections and pages.
  34. All non-Markdown files you add in a page/section directory will be copied alongside the generated page when the site is
  35. built, which allows us to use a relative path to access them.
  36. Pages with co-located assets should not be placed directly in their section directory (such as `latest-experiment.md`), but
  37. as an `index.md` file in a dedicated directory (`latest-experiment/index.md`), like so:
  38. ```bash
  39. └── research
  40. ├── latest-experiment
  41. │ ├── index.md
  42. │ └── yavascript.js
  43. ├── _index.md
  44. └── research.jpg
  45. ```
  46. With this setup, you may access `research.jpg` from your 'research' section
  47. and `yavascript.js` from your 'latest-experiment' page directly within the Markdown:
  48. ```Markdown
  49. Check out the complete program [here](yavascript.js). It's **really cool free-software**!
  50. ```
  51. By default, this page's slug will be the directory name and thus its permalink will be `https://example.com/research/latest-experiment/`.
  52. ### Excluding files from assets
  53. It is possible to ignore selected asset files using the
  54. [ignored_content](@/documentation/getting-started/configuration.md) setting in the config file.
  55. For example, say that you have an Excel spreadsheet from which you are taking several screenshots and
  56. then linking to these image files on your website. For maintainability, you want to keep
  57. the spreadsheet in the same directory as the Markdown file, but you don't want to copy the spreadsheet to
  58. the public web site. You can achieve this by setting `ignored_content` in the config file:
  59. ```
  60. ignored_content = ["*.xlsx"]
  61. ```
  62. ## Static assets
  63. In addition to placing content files in the `content` directory, you may also place content
  64. files in the `static` directory. Any files/directories that you place in the `static` directory
  65. will be copied, without modification, to the `public` directory.
  66. Typically, you might put site-wide assets (such as the site favicon, site logos or site-wide
  67. JavaScript) in the root of the static directory. You can also place any HTML or other files that
  68. you wish to be included without modification (that is, without being parsed as Markdown files)
  69. into the static directory.
  70. Note that the static directory provides an _alternative_ to co-location. For example, imagine that you
  71. had the following directory structure (a simplified version of the structure presented above):
  72. ```bash
  73. .
  74. └── content
  75. └── blog
  76.    ├── configuration
  77. │    └── index.md // -> https://mywebsite.com/blog/configuration/
  78.    └── _index.md // -> https://mywebsite.com/blog/
  79. ```
  80. To add an image to the `https://mywebsite.com/blog/configuration` page, you have three options:
  81. * You could save the image to the `content/blog/configuration` directory and then link to it with a
  82. relative path from the `index.md` page. This is the approach described under **co-location**
  83. above.
  84. * You could save the image to a `static/blog/configuration` directory and link to it in exactly the
  85. same way as if you had co-located it. If you do this, the generated files will be identical to those
  86. obtained if you had co-located the image; the only difference will be that all static files will be saved in the
  87. static directory rather than in the content directory. The choice depends on your organizational needs.
  88. * Or you could save the image to some arbitrary directory within the static directory. For example,
  89. you could save all images to `static/images`. Using this approach, you can no longer use relative links. Instead,
  90. you must use an absolute link to `images/[filename]` to access your
  91. image. This might be preferable for small sites or for sites that associate images with
  92. multiple pages (e.g., logo images that appear on every page).