Usually my URL for a post looks like this:
Well, I managed, that there’s no way to eliminate the /blog/ slug in Grav - if there is, please let me know
I also have problems with the rest. I use the slug: variable in item.md to change the slug the way I want. The .html works fine for me. But if I use numbers in the slug, they don’t show in the URL.
Usually the number is the ID for the post (which is good for search engines). But since there’s no way to use numbers in the slug, blog posts like »10 ways to strenghten your self confidence« wouldn’t work either.
Is there a workaround for that? Didn’t found anything in the documentation.
blog/ is there because the blog posts are subpages of the
You could add the posts as top-level pages, but then you’d need to rewrite their templates, and the homepage template to list them.
I just tested, the numbers in the slug (e.g.
slug: 10-test) work fine.
Well, if the blog page weren’t the home page,
blog/would be fine. But so it’s not very logical
I just tested it again… First
1-test.htmldoesn’t (404 error). I cleared the cache several times, now only
test.htmlworks, but I get a 404 again on each number I test.
The slug will use the folder name of the page by default. It automatically strips out any numbers in the formation
XX. (ie. XX.folder-name). So the resulting slug for a page in
03.folder-name will be
If you wish to have a numeric in the slug, then you should create your folder like this
10-test/ then you put your
post.md in that folder.
default.md is named to referenced the
default.html.twig template file from the theme to render the page. This is not related to the slug!
Hope that makes sense!
I didn’t touch the folder name at all. It’s like this:
I added a
slug: variable in the
item.md instead, like this:
title: This is the title
Without the number it works well with this method ;)
So i’m confused, it’s not working with:
slug: 1-this-is-the-title.html or it is?
Actually what you can do, rather than use a slug override, you can simply use a route alias:
This should let you reach
.html on the end should work without any extra config.
Yes, of course, but only without the numbers.
slug: this-is-the-title.htmlworks perfectly fine
Aliases aren’t an option for me… I start with about 150 blog posts. So I would start with 150 aliases and any other blog post would need another alias.
Hmm… can you please create an issue about the slugs here: https://github.com/getgrav/grav/issues
I think that is a bug, I need to look at it.