Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Problems duplicating blog.html.twig file

first-time theme

Solved by pamtbaau View solution

Started by Tina Ramey 6 years ago · 4 replies · 705 views
6 years ago

I'm just getting started with Grav, and starting digging into customizing the default theme. I wanted to duplicate, then tweak, the blog template. So, I replicated the blog.html.twig file (and renamed it to articles.html.twig). I made no other code changes to the file. However, when I selected that template for the parent page from the admin panel, the page no longer worked properly. The header showed up, but the items disappeared. What do I need to change in the duplicated file so that it works as expected?

Here is that page on my development site: http://christinar2.sg-host.com/grav/articles

6 years ago

@fidlet, Did you define the collection of blog pages in the frontmatter of articles.md ?

For example:

YAML
---
title: Articles
content:
    items: '@self.children'
    limit: '6'
    order:
        by: date
        dir: desc
    pagination: '1'
    url_taxonomy_filters: '1'
---

You can read more about collections in the docs: Page Collections

6 years ago

This is what I have in articles.md (it was generated by the admin panel):

YAML
---
title: Articles
child_type: article
hero_classes: ''
hero_image: ''
content:
    items: '- ''@self.children'''
    limit: '5'
    order:
        by: date
        dir: desc
    pagination: '1'
    url_taxonomy_filters: '1'
---
6 years ago Solution

@fidlet,

The following doesn't look right, and produces a page without any blog items:

TXT
items: '- ''@self.children'''

I would expect an error of some sort, but the page is working fine except for the lack of blog items.

Try:

TXT
items: '@self.children'

Suggested topics

Topic Participants Replies Views Activity
Support · by Paul Hodges, 4 weeks ago
19 491 6 days ago
Support · by Lauw, 1 week ago
2 107 1 week ago
Support · by Anna, 3 weeks ago
4 431 1 week ago
Support · by gtx, 4 weeks ago
4 380 3 weeks ago
Support · by Anna, 1 month ago
9 487 4 weeks ago