From f37b19db6af8316c0d13fe0eb532f18304d0936a Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 17 Jul 2018 17:58:58 +0200 Subject: [PATCH] Add archive docs Fix #307 --- .../documentation/templates/archive.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/content/documentation/templates/archive.md diff --git a/docs/content/documentation/templates/archive.md b/docs/content/documentation/templates/archive.md new file mode 100644 index 00000000..cf04c061 --- /dev/null +++ b/docs/content/documentation/templates/archive.md @@ -0,0 +1,23 @@ ++++ +title = "Archive" +weight = 90 ++++ + +Gutenberg doesn't have a built-in way to display an archive page, a page showing +all post titles ordered by year. However, this can be accomplished directly in the templates: + +```jinja2 +{% for year, posts in section.pages | group_by(attribute="year") %} +

{{ year }}

+ + +{% endfor %} +``` + +This snippet assumes that posts are sorted by date and that you want to display the archive +in a descending order. If you want to show articles in a ascending order, simply add a `reverse` filter +after the `group_by`.