-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blog slugs with numbers are unstable #443
Comments
So I just did a quick test of this. I added this in my page header:
And I was able to reach the page via:
Granted this is a bit deep in there, but the numerical slug alias did work. Also no problem with:
Can you check the content of your page file, by clicking on Expert mode or by looking directly at the |
BTW, you must not include |
the page extension is handled internally by Grav and defaults to |
I have it for test purposes in
With |
The addition of I'm very skeptical that your best practice structure is correct. numeric IDs in URLs is not semantic, and could only hinder your search results. In fact I know CMS such as Joomla that have IDs in their URLs are actively moving away from this to allow 100% text based URLs as these are considered better for SEO. Also in regards to your https://moz.com/blog/11-best-practices-for-urls In fact if you read here (from 2006), they say keep it simple. And specifically use descriptives and not numerics - (#4). |
Oh I will throw this out too: Do a google/yahoo search for "el capitan apache php" Notice anything interesting? http://getgrav.org/blog/mac-os-x-apache-setup-multiple-php-versions This page shows up in the top few search results. This is a pretty generic search query and not specific to our primary content at all, but the quality of content of this post plus Grav's SEO friendly routing and general features is ensuring this page shows up in the top few results. Long story short, I wouldn't obsess over this |
I totally agree with rhukster's statement here. But just for technical clarification if it works or nor, try using instead of the
I am curious whether that works for you. I used the default route concept to port legacy site across to Grav while maintaining their old-fashioned .html URLs so we don't disturb existing page rankings. |
@rhukster
They rank exceptionally good both in Google organic search and Google News. As a journalist I worked for one of them and I learned it from them. My blog (currently with Wordpress) uses these slugs for many years. And last, but not least, I spoke with a SEO professional about my blog a few days ago, and he pointed out, that my URL structure is perfect :) I want to leave WordPress (the security drives me nuts), so I found Grav. But those slugs are mandatory (despite some other things). The Do you mean in the |
I don't think a CMS should mandate a particular URL style. There may be recommendations and best practices which @rhukster outlined above but a discussion around this can be highly opinionated. So I recommend to leave it out of the discussion and let's focus on the technical capabilities of Grav and whether Grav gives you the freedom to implement your style or not. Btw, the default route only works on page level of course as it is a page specific setting. I changed one of my page's header to this (if you use the default route don't use the slug):
and Grav beautifully resolves a request to http://grav.local/123-contact.html So no issues here at all, your URL style works with Grav (tested with version RC4). |
@hwmaier
I flushed the cache and clicked in the blog at the post. The URL is perfect, but still: 404 :-| |
That looks correct. Do you type the url in your browser window or do you use a page link on another page? Try entering directly into the URL. |
@mirkoschubert your page header works for me if i remove the |
I think it could be possible to have a system setting to enable/disable the addition of the extension (eg This would resolve your problem because it would add And nope, i get an out of memory error with that as the slug also. Could be that my test site just has more plugins, more custom routes, more pages, etc. I have a lot of stuff in this test setup. The fact that it works is a bit of an accident anyway. My solution above would be a better solution and would work with everything. |
Strange this is. Now we have 3 different results. Could this be a difference in Grav versions used? @rhukster: An extension in the route.default should work as only then you can generate links and references with the wanted extension. As mentioned before I strongly lobby to keep the support for extensions in Grav (which btw currently works) in order to support site migrations. |
@rhukster: I don't think we need a system setting for this, as said it currently works here. A page should be able to define its own default route and I have even sites which have a mix of extensions. Some .html, some .php and some with a trailing slash. currently Grav copes with all of this if route.default is used. So a system wide setting would not work for this either. |
I think the problem i'm having is purely based on the size and complexity of my test site, and the fact that |
No, like i said, it works by accident and is not reliable. It's also going to break in other places where routes are matched (probably multilang too). |
That said, could be site-wide with page override like we have used many times before. That way you can have:
Basically this covers all the bases with the minimal amount of fuss. |
However, before I look at that i'll check to see what's causing my memory issue, and maybe its fixable. Would mean you would have to set a default route/slug for EVERY page individually with no option to have it automatic for every page on your site (like joomla/wordpress does). |
@hwmaier: I use Grav 1.0.0 RC4 without the Admin Plugin and the Grav Blog Skeleton/ Antimatter with all their plugins and an own (inherited) theme with the changes. @rhukster: You're right, without the |
@mirkoschubert Did you test the URL by entering it into the browser address line? |
@rhukster I have a legacy site where I have hardcoded every page with it default route. This is no issue for me as this is a special case, a legacy site so to speak. For that site I am completely bybassing the slug mechanism. I actually even like this approach as I can keep URLs with the content and it does not depend on file/directory structure. |
Like i said, putting .html in the default route is working by accident :) We can do better. |
@hwmaier I did both: I entered it in the browser address line and I followed the links on the blog summary - same result. |
I actually get a 404 like @mirkoschubert when i put |
Ah, you just reminded me that I had to set
|
As I mentioned, I don't get an 404 if I use the |
I don't think the digit ID part has anything to do with things. Works for me as expected if I use a numeric ID or not. There's no logic to discern that from a regular string. |
@hwmaier Tested. Works for me as well :) |
Guys, the pages.types is the difference. Once set to empty Grav honours the extension, otherwise it discards it for route matching. |
I know it works, but your approach could potentially break things. By removing the valid page types, your basically just skipping the step where Grav strips the extension from the route. This route is used throughout grav, and could potentially break plugins and multilang where it's expected to be a route and not include the file extension. What i'm proposing would not change that 'workaround' you have, but would let you do this properly. |
If it can be done properly, I would take this willingly :) |
@rhukster Official support is most welcome, and it helps "site migrants" tremendously. I am happy to assist constructively and with coding if needed as I have done in the past. |
commit e96445a should address this. Basically there is now a setting in
By default it's an empty string, but if you provide an extension here, eg
And it will append that for only this specific page. The
You can also provide a custom extension such as:
But you need to add |
Thanks for adding this so quickly, this is a welcome addition.
|
In addition to the page-level
this could be expressed simpler as:
The latter could also work for a directory name This should be easy to do, if a slug with an extension is detected it is removed and set as append_url_extension value. |
The approach I pursued was based on minimal impact to nearly stable Grav balanced with maximum flexibility and functionality to achieve the goals needed, combined with as much ease of use as possible... I appreciate your ideas, but there are very good reasons why each of them has issues:
Lastly I feel like this is a pretty niche thing. The majority of people using Grav would never use this. Those that are moving from other platforms could simply use We'll just make sure to clearly document it. |
If I use
slug: this-is-a-title.html
in anitem.md
(e.g. for an blog post), it works perfectly fine. But if I use slugs with numbers, e.g.slug: 10-this-is-a-title.html
it sometimes works, but sometimes the slug of the blog post in Grav is shown without the number or even worse, the whole blog post gets an 404 error.I use Grav 1.0.0-RC4 without Admin-Plugin and with the Blog Skeleton (Antimatter).
The text was updated successfully, but these errors were encountered: