Update docs for sitemap
This commit is contained in:
parent
2a0d0b9b77
commit
7baf08cef2
|
@ -8,6 +8,7 @@ a section
|
|||
- The table of content for a page/section is now only available as the `toc` variable when
|
||||
rendering it and not anymore on the `page`/`section` variable
|
||||
- Default directory for `load_data` is now the root of the site instead of the `content` directory
|
||||
- Change variable sent to the sitemap template, see documentation for details
|
||||
|
||||
### Other
|
||||
- Add support for content in multiple languages
|
||||
|
@ -17,6 +18,7 @@ rendering it and not anymore on the `page`/`section` variable
|
|||
- Add Dracula syntax highlighting theme
|
||||
- Fix using inline styles in headers
|
||||
- Fix sections with render=false being shown in sitemap
|
||||
- Sitemap is now split when there are more than 30 000 links in it
|
||||
|
||||
|
||||
## 0.5.1 (2018-12-14)
|
||||
|
|
|
@ -881,7 +881,7 @@ impl Site {
|
|||
if total_number < sitemap_limit {
|
||||
// Create single sitemap
|
||||
let mut context = Context::new();
|
||||
context.insert("sitemap_entries", &all_sitemap_entries);
|
||||
context.insert("entries", &all_sitemap_entries);
|
||||
let sitemap = &render_template("sitemap.xml", &self.tera, context, &self.config.theme)?;
|
||||
create_file(&self.output_path.join("sitemap.xml"), sitemap)?;
|
||||
return Ok(())
|
||||
|
@ -891,7 +891,7 @@ impl Site {
|
|||
let mut sitemap_index = Vec::new();
|
||||
for (i, chunk) in all_sitemap_entries.chunks(sitemap_limit).enumerate() {
|
||||
let mut context = Context::new();
|
||||
context.insert("sitemap_entries", &chunk);
|
||||
context.insert("entries", &chunk);
|
||||
let sitemap = &render_template("sitemap.xml", &self.tera, context, &self.config.theme)?;
|
||||
let file_name = format!("sitemap{}.xml", i+1);
|
||||
create_file(&self.output_path.join(&file_name), sitemap)?;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
{% for sitemap_entry in sitemap_entries %}
|
||||
{% for sitemap_entry in entries %}
|
||||
<url>
|
||||
<loc>{{ sitemap_entry.permalink | safe }}</loc>
|
||||
{% if sitemap_entry.date %}
|
||||
|
|
|
@ -6,20 +6,27 @@ weight = 60
|
|||
Zola will look for a `sitemap.xml` file in the `templates` directory or
|
||||
use the built-in one.
|
||||
|
||||
If your site has more than 30 000 pages, it will automatically split
|
||||
the links into multiple sitemaps as recommended by [Google](https://support.google.com/webmasters/answer/183668?hl=en):
|
||||
|
||||
The sitemap template gets four variables in addition of the config:
|
||||
> All formats limit a single sitemap to 50MB (uncompressed) and 50,000 URLs.
|
||||
> If you have a larger file or more URLs, you will have to break your list into multiple sitemaps.
|
||||
> You can optionally create a sitemap index file (a file that points to a list of sitemaps) and submit that single index file to Google.
|
||||
|
||||
- `pages`: all pages of the site
|
||||
- `sections`: all sections of the site, including an index section
|
||||
- `tags`: links the tags page and individual tag page, empty if no tags
|
||||
- `categories`: links the categories page and individual category page, empty if no categories
|
||||
In such a case, Zola will use a template called `split_sitemap_index.xml` to render the index sitemap.
|
||||
|
||||
As the sitemap only requires a link and an optional date for the `lastmod` field,
|
||||
all the variables above are arrays of `SitemapEntry` with the following type:
|
||||
|
||||
The `sitemap.xml` template gets a single variable:
|
||||
|
||||
- `entries`: all pages of the site, as a list of `SitemapEntry`
|
||||
|
||||
A `SitemapEntry` has the following fields:
|
||||
|
||||
```ts
|
||||
permalink: String;
|
||||
date: String?;
|
||||
```
|
||||
|
||||
All `SitemapEntry` are sorted in each variable by their permalink.
|
||||
The `split_sitemap_index.xml` also gets a single variable:
|
||||
|
||||
- `sitemaps`: a list of permalinks to the sitemaps
|
||||
|
|
Loading…
Reference in a new issue