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.

installing-and-using-themes.md 2.2KB

7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. +++
  2. title = "Installing & using themes"
  3. weight = 20
  4. +++
  5. ## Installing a theme
  6. The easiest way to install to theme is to clone its repository in the `themes`
  7. directory.
  8. ```bash
  9. $ cd themes
  10. $ git clone THEME_REPO_URL
  11. ```
  12. Cloning the repository using Git or another VCS will allow you to easily
  13. update it but you can also simply download the files manually and paste
  14. them in a folder.
  15. You can find a list of themes [on this very website](./themes/_index.md).
  16. ## Using a theme
  17. Now that you have the theme in your `themes` directory, you only need to tell
  18. Zola to use it to get started by setting the `theme` variable of the
  19. [configuration file](./documentation/getting-started/configuration.md). The theme
  20. name has to be name of the directory you cloned the theme in.
  21. For example, if you cloned a theme in `themes/simple-blog`, the theme name to use
  22. in the configuration file is `simple-blog`.
  23. ## Customizing a theme
  24. Any file from the theme can be overriden by creating a file with the same path and name in your `templates` or `static`
  25. directory. Here are a few examples of that, assuming the theme name is `simple-blog`:
  26. ```plain
  27. templates/pages/post.html -> replace themes/simple-blog/templates/pages/post.html
  28. templates/macros.html -> replace themes/simple-blog/templates/macros.html
  29. static/js/site.js -> replace themes/simple-blog/static/js/site.js
  30. ```
  31. You can also choose to only override parts of a page if a theme define some blocks by extending it. If we wanted
  32. to only change a single block from the `post.html` page in the example above, we could do the following:
  33. ```
  34. {% extends "simple-blog/templates/pages/post.html" %}
  35. {% block some_block %}
  36. Some custom data
  37. {% endblock %}
  38. ```
  39. Most themes will also provide some variables that are meant to be overriden: this happens in the `extra` section
  40. of the [configuration file](./documentation/getting-started/configuration.md).
  41. Let's say a theme uses a `show_twitter` variable and sets it to `false` by default. If you want to set it to `true`,
  42. you can update your `config.toml` like so:
  43. ```toml
  44. [extra]
  45. show_twitter = false
  46. ```
  47. You can modify files directly in the `themes` directory but this will make updating the theme harder and live reload won't work with those
  48. files.