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.
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).
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.
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.
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 http://yoursite.com, 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.
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.
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?
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.