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 · 594 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 Water Science, 3 weeks ago
11 167 6 hours ago
Support · by Duc , 21 hours ago
1 44 21 hours ago
Support · by Thomas, 1 week ago
3 116 1 day ago
Support · by Anna, 4 days ago
2 109 2 days ago
Support · by Justin Young, 2 days ago
1 87 2 days ago