Removing 'blog' from url

I’m having a hard time trying to figure out how to completely remove the word blog from all urls while (obviously) keeping all the funcionality from the pages.

For instance:
"/blog/classic-modern-architecture" should be “/classic-modern-architecture”
"/blog/page:2" should be "/page:2"
and so on…
Thanks in advance!

i think you’ll find you have your site installed in a directory called blog. For you to have your URLs without the blog path you will need to install Grav in the root of your webroot directory rather than in a the blog subfolder.

eg public_html/ rather than in public_html/blog

In fact, my site is installed in a directory called ‘grav-skeleton-blog-site’ but I’ve set up my virtual hosts correctly so that I can access it using something like: myurl.local (or localhost/grav-skeleton-blog-site/, but that’s not the case).

This way, when I access myurl.local or myurl.local/blog, I go to home, which is ok.
The problem is that all the other links point to a url with blog included. For example, the first blog post points to myurl.local/blog/sunshine-in-the-hills and I wished it to point to myurl.local/sunshine-in-the-hills.

The only exception are the urls generated by some plugins like pagination, and archives that point to a url without the word blog (like, myurl.local/page:2) but they result in a 403 error.and only work if I include the ‘path’ to blog in it, (like, myurl.local/blog/page:2).

Is there anything I can do to get this working??

Thanks once more!

I did make some changes in the last week that changes how the plugins get the path to the list view. Are you all up to date with plugins and have all the changes from the latest Antimatter template updates? Knowing that will help me help you further. Cheers.

I’m working on a fresh blog skeleton from the site so I think everything is up to date.
I’ve already tried to route in apache and play with aliases and routes in grav configs with no success…

I’m trying to figure out if there’s a way to achieve similar behavior of what the alias for home (user/config/system.yaml:4) does, that worked for every page in the blog.

just an idea but wouldn’t it be possible to do this by mod_rewrite rules in your .htaccess? have a look at these examples:

have a lot of fun

That was my first try but I wasn’t able to make it work properly and it only gives me 404s. I’m probably doing something wrong but I couldn’t figure out what.

This is not a bug only specific to this user. It happens with the blog demo at:
Just hover the pointer over the first post title, and you get:
…as the link.
So, “/blog/” is included. And it shouldn’t be, right?

if you have a folder called user/blog where you blog is located, then yes that is a feature/limitation of Grav. Basically you can alias one url as the home.

So f you set /blog as home, then that will show you the blog at, but any subpages don’t know that, so they are going to have blog in their URL. If you were to change your home to something else, they would and should still have blog in their URL.

This is not a bug, it’s just how the routing works.

So I have to create a route for every blog post to achieve that? Is this OK (from a performance standpoint, etc.)?

No you shouldn’t have to create a route, because it shouldn’t be a problem. blog posts under the blog/ folder will have blog in them, but they should work fine.

I guess it would be helpful to see a live-site to see what the actual problem is. I’m a bit confused at this point.

You see, from an SEO perspective, pages with URLs without the “/directory/” part used to be (I don’t know if it’s still the case) considered more relevant by Google than ones with a directory in it.

Having all your URLs at the root of your site is actually a common misconception about SEO. As long as your URL contains an accurately named slug for the page, you will be fine.

It’s much more important to have solid content, in-links, and other factors. Google, and other search engines have long been smart enough to not fall for anything that is a quick ‘trick’, or ‘hack’ that is not directly related to your content.

Trying to convince a search engine that your page is more important because its a root URL could theoretically get you penalized.

Your best bet is to focus on the quality of your content, and the clarity of your overall content structure. Then get the word out about your content via social media to try to gain links.

I see… Any more tips? :wink:

Just to prove this point :slight_smile:

Grav, a very new project, with a very new site, searching for some pretty generic terms: “apache php yosemite”

The article I did on this on the site (with blog/ url), shows up #4 for me in Google!

Wow! This is great. :slight_smile: For me it’s #5. OK, I will keep focusing on providing great content, and having clear “slugs”. :slight_smile:

Hey rhukster and andrelima!

Thanks for all the info on the SEO subject. Unfortunately, my problem is not a matter of SEO and I do need to make Grav work without the blog ‘directories’ in all the urls.

I still wasn’t able to do that in apache and according to what rhukster said (or to what I understood) it seems not to be possible to do this.

Is there anything I can do in order to ‘solve’ this feature or should I just give up?

Thanks once more!

@robyflc I guess i’m not clearly getting what exactly your problem is?

I’ll quote myself:

For instance:
“/blog/classic-modern-architecture” should be “/classic-modern-architecture”
“/blog/page:2” should be “/page:2”
and so on…

Since I will only have the blog in my domain, I want to be able to navigate in it without having the ‘directory’ blog in my urls.

Using the blog skeleton as an example,

the link for the first post is:
and is should be:

the link for the second post is:
and it should be:

I hope the issue is clear now.
I just want to know if there’s a correct way or a hack or anything that could led me to a desirable solution.

Thanks once more!

My question is why do you want to have it without the blog/ in the urls? Why is this a problem?

Unless you have these pages at the top level of your site (eg. /user/pages/sunshine-in-the-hills), they will always have the blog slug to them in the URL. This is by design to provide no-configuration-required routing.

You can use custom routes to have a list of route alias, but this is not very practical for lots of pages.

Grav is intentionally designed to be simple, and routing is a complex problem. I can see us adding more powerful routing options in the future, but other things are more important at the moment.