No numbers in the slug?

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 :wink:
I also have problems with the rest. I use the slug: variable in 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 blog page.
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 :wink:
I just tested it again… First 10-test.htmlworked, but 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 /folder-name.

If you wish to have a numeric in the slug, then you should create your folder like this 10-test/ then you put your or in that folder.

This 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 instead, like this:
— yaml
title: This is the title
slug: 1-this-is-the-title.html

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:

      - '/1-this-is-the-title'

This should let you reach /blog/this-is-the-title as /1-this-is-the-title. The .html on the end should work without any extra config.

BTW more info on routes and aliases in the docs

Yes, of course, but only without the numbers. slug: this-is-the-title.htmlworks perfectly fine :wink:
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:

I think that is a bug, I need to look at it.

Done :wink: