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

Best way to add a post's date to the URL slug

Started by Muut Archive 10 years ago · 1 replies · 1125 views
10 years ago

Hello,

Great work with Grav—it's my favorite system I've tried by far—and I've tried them all.

I've been racking my brain for the last hour trying to figure out how to add a post's date to the slug used for the post's URL (or permalink).

Currently, I am using the Cacti theme, and am hiding the "/blog" folder structure so it doesn't appear in the URLs.

I am trying to create the following post URL format:

mydomain.com/2016/09/03/my-post-title

The only post I could find on the matter was this one: https://getgrav.org/forum#!/general:blog-permalink-format

I wasn't able to get the routing to work however, even when adding the hyphenated dates to the folder name.

My guess is that I may be missing something super obvious, or perhaps there is a setting I haven't updated. Any guidance would be extremely helpful since having a post date in the URL is critical for me.

Thanks again!

10 years ago

You can simply structure the page folders with dates. However instead of the blog listing page using @page.children, you'll need to use @page.descendants or @taxonomy as the pages wont be direct children.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1361 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1123 9 years ago