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.

README.md 6.1KB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Gutenberg
  2. [![Build Status](https://travis-ci.org/Keats/gutenberg.svg?branch=master)](https://travis-ci.org/Keats/gutenberg)
  3. [![Build status](https://ci.appveyor.com/api/projects/status/h4t9r6h5gom839q0/branch/master?svg=true)](https://ci.appveyor.com/project/Keats/gutenberg/branch/master)
  4. An opinionated static site generator written in Rust.
  5. ## Installation
  6. You can get the latest release by going to the [Release page](https://..).
  7. Alternatively, if you have the rust toolchain on your computer, you can also install it
  8. through Cargo: `cargo install gutenberg`.
  9. ## Usage
  10. ### Creating a new site
  11. Use `gutenberg init <a_directory_name>`.
  12. This will create a folder with the name given and the base structure of a gutenberg site.
  13. ### Working on a site
  14. Use `gutenberg serve` to spin up a server that will automatically live reload any changes to the
  15. content, templates or static files.
  16. ### Building a site
  17. Use `gutenberg build` to generate the site in the `public/` directory.
  18. ### Gutenberg terms
  19. Some words are going to be repeated in the docs so let's make sure they are clear.
  20. - Page: a markdown file in the `content` directory that has a name different from `_index.md`
  21. - Section: a group of pages in the `content` directory that has `_index.md` in the same folder
  22. ### Configuration
  23. Configuration is using the [TOML](https://github.com/toml-lang/toml) language.
  24. Only 2 parameters are required: `title` and `base_url`.
  25. The other options are:
  26. - `highlight_code`: Whether to highlight all code blocks found in markdown files. Defaults to false
  27. - `highlight_theme`: Which themes to use for code highlighting. Defaults to "base16-ocean-dark"
  28. - `language_code`: The language used in the site. Defaults to "en"
  29. - `generate_rss`: Whether to generate RSS, defaults to false
  30. - `generate_tags_pages`: Whether to generate tags and individual tag pages if some pages have them. Defaults to true
  31. - `generate_categories_pages`: Whether to generate categories and individual category categories if some pages have them. Defaults to true
  32. If you want to add some of your own variables, you will need to put them in the `[extra]` table in `config.toml` or
  33. they will be silently ignored.
  34. ### Templates
  35. Templates live in the `templates/` directory.
  36. Only [Tera](https://github.com/Keats/tera) templates are supported.
  37. Each kind of page get their own variables:
  38. // TODO: detail the schema of the variables
  39. - index.html: gets `pages` that contain all pages in the site
  40. - page.html: gets `page` that contains the data for that page
  41. - section.html: gets `section` that contains the data for pages in it and its subsections
  42. - tags.html: gets `tags`
  43. - tag.html: gets `tag` and `pages`
  44. - categories.html: gets `categories`
  45. - category.html: gets `category` and `pages`
  46. Additionally, all pages get a `config` variable representing the data in `config.toml`.
  47. If you want to know all the data present in a template content, simply put `{{ __tera_context }}`
  48. in the templates and it will print it.
  49. ### Static files
  50. Everything in the `static` folder will be copied into the output directory as-is.
  51. ### Pages
  52. Pages have to start with a front-matter enclosed in `+++`. Here is a minimal example:
  53. ```md
  54. +++
  55. title = "My page"
  56. description = "Some meta info"
  57. +++
  58. A simple page with fixed url
  59. ```
  60. A front-matter requires a title, a description and has the following optional variables:
  61. - date: a YYYY-MM-DD or RFC339 formatted date
  62. - slug: what slug to use in the url
  63. - url: this overrides the slug and make this page accessible at `{config.base_url}/{url}`
  64. - tags: an array of strings
  65. - category: only one category is allowed
  66. - draft: whether the post is a draft or not
  67. - template: if you want to change the template used to render that specific page
  68. You can also, like in the config, add your own variables in a `[extra]` table.
  69. The front-matter will be accessible in templates at the `page.meta` field.
  70. By default, the URL of a page will follow the filesystem paths. For example, if you have
  71. a page at `content/posts/python3.md`, it will be available at `{config.base_url}/posts/python3/`.
  72. You can override the slug created from the filename by setting the `slug` variable in the front-matter.
  73. Quite often, a page will have assets and you might want to co-locate them with the markdown file.
  74. Gutenberg supports that pattern out of the box: you can create a folder, put a file named `index.md` and any number of files
  75. along with it that are NOT markdown.
  76. Those assets will be copied in the same folder when building so you can just use a relative path to use them.
  77. A summary is only defined if you put `<!-- more -->` in the content. If present in a page, the summary will be from
  78. the start up to that tag.s
  79. ### Sections
  80. Sections represent a group of pages, for example a `tutorials` section of your site.
  81. Sections are only created in Gutenberg when a file named `_index.md` is found in the `content` directory.
  82. This `_index.md` file needs to include a front-matter as well, but won't have content:
  83. ```md
  84. +++
  85. title = "Tutorials"
  86. description = ""
  87. +++
  88. ```
  89. Both `title` and `description` are mandatory, you can also set the `template` variable to change
  90. which template will be used to render that section.
  91. Sections will also automatically pick up their subsections, allowing you to make some complex pages layout and
  92. table of contents.
  93. ### Code highlighting themes
  94. Code highlighting can be turned on by setting `highlight_code = true` in `config.toml`.
  95. When turned on, all text between backticks will be highlighted, like the example below.
  96. ```rust
  97. let site = Site::new();
  98. ```
  99. If the name of the language is not given, it will default to plain-text highlighting.
  100. Gutenberg uses Sublime Text themes for syntax highlighting. It comes with the following theme
  101. built-in:
  102. - base16-ocean-dark
  103. - base16-ocean-light
  104. - gruvbox-dark
  105. - gruvbox-light
  106. - inspired-github
  107. - kronuz
  108. - material-dark
  109. - material-light
  110. - monokai
  111. - solarized-dark
  112. - solarized-light
  113. A gallery containing lots of themes at https://tmtheme-editor.herokuapp.com/#!/editor/theme/Agola%20Dark.
  114. More themes can be easily added to gutenberg, just make a PR with the wanted theme.
  115. ## Example sites
  116. - [vincent.is](https://vincent.is): https://gitlab.com/Keats/vincent.is