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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

URL path structure

Started by Lou 7 years ago · 4 replies · 459 views
7 years ago

I'm trying to migrate a wordpress blog to Grav & I have a few questions:

In wordpress you use categories to structure breadcrumbs. So, for the article "Tasty Homemade Cat Food Recipes" I would have:

Pets (main category)
Cats (sub category of pets)
Cat Food (Sub category of Cats)

Then I would assign my article to the Cat Food category.

Name my article would be named: Tasty Homemade Cat Food Recipes.

It would produce the URL mydomain/tasty-homemade-cat-food-recipes/

The breadcrumb structure would look like this: Pets > Cats > Cat Food > Tasty Homemade Cat Food Recipes

With Grav if I make a blog post nested within a blog post I get this url: mydomain/pets/cats/cat-food/tasty-homemade-cat-food-recipes/

Doing so does give me the breadcrumb structure: Pets > Cats > Cat Food > Tasty Homemade Cat Food Recipes

That is what I want. However, the URL is not what I want. Also, I don't understand how to get the categories going.

My question is:

How do I make the blog folders like this: mydomain/pets/cats/cat-food/tasty-homemade-cat-food-recipes/

But have the url to access it like this: mydomain/tasty-homemade-cat-food-recipes/

7 years ago

you can change route in your article blueprint
with /tasty-homemade-cat-food-recipes
48|690x93

… Welcome to Grav Community 😀

7 years ago

Ok thanks for the help. I'm not using the admin panel. I figured out that I can add this to the page headers:

YAML
routes:
default: /tasty-homemade-cat-food-recipes

Now, when I try to do it site-wide by editing the user/config/site.yaml file it doesn't work.

What's the code to replicate this in the site.yaml file?

7 years ago

you have to edit your article frontmatter (each article) ex: item.md

YAML
routes:
    default: /tasty-homemade-cat-food-recipes

or make a plugin to do it auto
but maybe i misunderstand what you want to achieve

7 years ago

So, I read here: https://learn.getgrav.org/16/content/routing#regex-based-aliases

That you can edit the user/config/site.yaml & you can change the url structure for all blog posts. So instead of going into each blog post individually & doing this:

YAML
routes:
default: /tasty-homemade-cat-food-recipes

According to the document I can edit user/config/site.yaml & put something like this:

TXT
routes:
   /blog/(.*): /$1

My understanding is that this way, I don't have to go into each individual blog post to add the route.

However, when I do this: /blog/(.*): /$1 it create blank pages, if you click on the url. Do I have the code wrong or do I am I missing something?

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 9 hours ago
Support · by Anna, 3 days ago
2 59 12 hours ago
Support · by Justin Young, 13 hours ago
1 30 13 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago