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

Group blog items by year -> redirect and appearance question

Started by Muut Archive 9 years ago · 9 replies · 712 views
9 years ago

I implemented a blog, and since the list of blog posts will get enormous, i would like to atleast group the blog items by year in a folder:
/blog/2017/ <--- lots of blog items in here
/blog/2018/ <--- lots of blog items in here
/blog/2019/ <--- lots of blog items in here

The problem is, that once i put the blog items in a Folder, the blog items located for example in /blog/2018 won't show up in /blog. Only the Folders which shouldn't show up are rendered in the blog:
Blog item list on /blog/ page:
2017
2018
2019

So how can i get grav to show the items located inside the folder 2017,2018,2019, but not the folders themselves?

Kind regards,

Smash

9 years ago

@rhukster with your recomendation the example is possible but following that configuration there will be posts called 2017, 2018, 2019, etc.
Is it possible to hide the 2017, 2018 and 2019 pages from home page? (but not the 2017 or 2018 or 2019 children pages?)

9 years ago

Maybe it's possible by using '@page.children': '/blog/2017' and so on. Haven't tried it yet. Will report back.

9 years ago

Perhaps it's even possible to use a wildcard here... '@page.children': ‘/blog/* --> Off to test it out

9 years ago

This does work:
content:
items:

  • '@page.descendants': /blog/2017
  • '@page.descendants': /blog/2018
    What doesn't work is using a wildcard

Thank you for your input, rhukster!
And thank you barbanet for pointing out that using @self.descendants doesn't hide the folders.

9 years ago

Also you can set published false in those year pages.

9 years ago

@Smash,

How are you adding two items to the same content?
I've tried changing the md file and using the admin but it seems not possible with a vanilla installation.

Also, using folders I've found tags are using the folder in the url (well, all my tags has stopped to work but maybe was me)

9 years ago

There's another issue (?) with this approach. Using Grav as blog with folders to group posts your pagination will work only with posts inside that folder.

9 years ago

Also you can set published false in those year pages
Thats the first thing i tried. if i remember correctly that resulted in the subpages not being published by default, or not at all
How are you adding two items to the same content? I've tried changing the md file and using the admin but it seems not possible with a vanilla installation.
I also couldn't get it to work via the admin panel, more precisely, using the admin panel, only one item could be added, and only if the statement was written in one line (Complete file content follows):

YAML
title: Blog
content:
items:
- '@page.descendants': /blog/2017
- '@page.descendants': /blog/2018
limit: 5
order:
by: date
dir: desc
pagination: true
url_taxonomy_filters: true

Also, using folders I've found tags are using the folder in the url (well, all my tags has stopped to work but maybe was me)
Can you elaborate in more detail? how are the tags (taxonomy?) using the folder?
There's another issue (?) with this approach. Using Grav as blog with folders to group posts your pagination will work only with posts inside that folder.
Do you mean the pages inside blog/ folder don't show anymore?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1332 9 years ago
Archive · by Muut Archive, 9 years ago
2 923 9 years ago
Archive · by Muut Archive, 9 years ago
2 4053 9 years ago
Archive · by Muut Archive, 9 years ago
1 2931 9 years ago
Archive · by Muut Archive, 9 years ago
3 1109 9 years ago