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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. +++
  2. title = "Overview"
  3. weight = 10
  4. +++
  5. Gutenberg uses the [Tera](tera.netlify.com) template engine.
  6. This documentation will only touch how templates work in Gutenberg, please read
  7. the [Tera template documentation](https://tera.netlify.com/docs/templates/) if you want
  8. to know how write them. If you are familiar with Jinja2, Liquid or Twig, this should be
  9. a breeze.
  10. All templates live in the `templates` directory and built-in or themes templates can
  11. be overriden by creating a template with same name in the correct path. For example,
  12. you can override the RSS template by creating a `templates/rss.xml` file.
  13. If you are not sure what is available in a template, you can just stick `{{ __tera_context }}` in it
  14. to print the whole context.
  15. A few variables are available on all templates except for RSS/Sitemap:
  16. - `config`: the [configuration](./documentation/getting-started/configuration.md) without any modifications
  17. - `current_path`: the path (full URL without the `base_url`) of the current page
  18. - `current_url`: the full URL for that page
  19. ## Built-in filters
  20. Gutenberg adds a few filters, in addition of the ones already present in Tera.
  21. ### markdown
  22. Converts the given variable to HTML using Markdown. This doesn't apply any of the
  23. features that Gutenberg adds to Markdown: internal links, shortcodes etc won't work.
  24. ### base64_encode
  25. Encode the variable to base64.
  26. ### base64_decode
  27. Decode the variable from base64.
  28. ## Built-in global functions
  29. Gutenberg adds a few global functions to Tera in order to make it easier to develop complex sites.
  30. ### `get_page`
  31. Takes a path to a `.md` file and returns the associated page
  32. ```jinja2
  33. {% set page = get_page(path="blog/page2.md") %}
  34. ```
  35. ### `get_section`
  36. Takes a path to a `_index.md` file and returns the associated section
  37. ```jinja2
  38. {% set section = get_page(path="blog/_index.md") %}
  39. ```
  40. ###` get_url`
  41. Gets the permalink for the given path.
  42. If the path starts with `./`, it will be understood as an internal
  43. link like the ones used in markdown.
  44. ```jinja2
  45. {% set url = get_url(path="./blog/_index.md") %}
  46. ```
  47. This can also be used to get the permalinks for static assets for example if
  48. we want to link to the file that is located at `static/css/app.css`:
  49. ```jinja2
  50. {{ get_url(path="css/app.css") }}
  51. ```
  52. In the case of non-internal links, you can also add a cachebust of the format `?t=1290192` at the end of a URL
  53. by passing `cachebust=true` to the `get_url` function.