-
Notifications
You must be signed in to change notification settings - Fork 26
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
Route localization attempt based on the translated slugs #50
Conversation
…h the pages hierarchy
This should fix issue #39. I got the same problem using the sitemap plugin, I submitted there another pull request with almost the same code. Probably the best way would be to have the common code in the Grav core. |
This fix works on my project, thank you @flagar ! |
@rhukster Please review this, because it's pretty important for SEO. The meta template should also be changed to use this function. |
Reviewing and approving this PR would be very beneficial for the plugin (and for our ability to use Grav for multi-language sites) |
why hasn't it been implemented in the real version yet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it's taken so long to get around to testing this, but it looks pretty good! I'm going to accept it. Thanks.
Hi @rhukster it is missing the x-default language in the header bye |
Perhaps some important details on this issue reported by @maofree Important is to note that the issue reported by @maofree, meaning Grav is appending the folder name to the URL displayed in the browser bar when clicking on another language, apparently only happens with the 'root page' (e.g. 01.home) but not with the child folders inside 'home'. At least on my test site. I have disabled all Here is an exampleTest preconditions:
Steps:
NOTE: This issue appears to be exclusive to the 'home' folder, i.e. the websites 'root', often '01.home'. I cannot reproduce this issue with the home folder's siblings. As said above, I don't have this issue with the child folders inside 'home'. UPDATE 1: I have found out that, for the default language, 'home' IS NOT being appended to the domain in the browser address bar if your default language file name DOES NOT contain the country code, e.g. default.md instead of default.en.md. (But 'home' is still appended to the secondary language, which naturally contains the country code in the file name in any case.) In my tests, I have used the 'Learn2' (Hibbitts Design) and the 'OpenPublishing Space' (Hibbitts Design) skeletons. The issue is the same for both skeletons. Slugs seems to be neglected when switching back to the default language + workaroundI don't know if this is related to the above but when somewhere on a nested page, e.g. home/sub/subsub, and switching back from the secondary language to the default language, the folder path is shown in the browser address bar instead of the slugs. However, when clicking on the secondary language again, the slug path is correctly displayed in the browser address bar for the given secondary language. If one switches back to EN, the folder path is displayed again. HOWEVER: If |
what would really help would be a little package of system config + sample |
@rhukster -- the 'system config' file and everything included in 'pages' ? Before downloading that, would you prefer to have access to my system? |
Hi @rhukster and @godfatherjohn it is necessary to add the x-default language into templates/partials/langswitcher.hreflang.html.twig before the end line instead on the home voice at the end of the url is present on the lang selector I get the home problem on a website included in a sub-folder, the problem is present only in the homepage for each languages look at this video I've solved this problem with this code editing but a guy said me that it is present a problem with multi-website solution, so it is necessary to add the shop extension the langswitcher.html.twig is changed to us the bootstrap dropdown for the lang selector |
@maofree - I'm not sure if I have understood correctly. Generally, I cannot really see the point in adding the On adding the line I'm asking because the code in your second screenshot is the entire code from the file langswitcher.hreflang.html.twig and comes with the plugin (here on Github) by default. As such, it is the exact code I use in my setup. I cannot see the In your screencast video, you seem to be in the home directory of your website, is that correct? What is the behaviour when you go to the 'About' page of you site and then switch languages? Does 'home' still come up in the address bar? |
@rhukster If it helps, the page I mentioned is actually on Trilby hosting, so feel free to take a look in there -- |
@yankl - Maybe it would be better to discuss the path issue in the corresponding post (#69), to keep things tidy. @maofree - on the 'home' added to address, I have further looked in this issue. Question for you, does your default language file name have the country code in it, e.g. default.it.md instead of default.md? I'm asking because I have found out that, for the default language, 'home' IS NOT being appended to the domain in the browser address bar if your default language file name DOES NOT contain the country code, e.g. default.md instead of default.it.md. (assuming IT is your default language). (But 'home' is still appended to the secondary language, which naturally contains the country code in the file name in any case.) Note 1: that I can still only reproduce this issue for the website's root directory (i.e. the homepage, usually in folder '01.home'). Note 2: In my tests I have used the 'Learn2' (Hibbitts Design) and the 'OpenPublishing Space' (Hibbitts Design) skeletons. The issue is the same for both skeletons. Could you get back on the question from last night: I believe that adding the |
@maofree -- - |
@godfatherjohn the problem is limited only to the homepage, because it is the only page of the site that does not have a slug, for all the other pages there are no problems because the slug variable has a value I've done a test |
@maofree Apparently, something got messed up with considering the .md files in a folder and their endings, and this trickles down to adding the 'home' folders actual name to the domain. Thanks for confirming that the issue is only present on the homepage, not on subpages. |
I confirm that if I remove it from modular.it.md the home will remove from the url, but for the rest of languages I continue to get the home I think the problem is around the slug, in the homepage is void and grav adds home the name of folder |
Further up you were saying it happens with the subdirectories too, therefore it's good to see that this is not the case. Hence we have pretty much nailed down the issue, that should make fixing it easier. Exactly, because your secondary languages have the country code in the file name (default.COUNTRYCODE.md). |
Nope, the issue persists, no matter if you use slugs or not. But maybe the folder name is read and falsely assigned to the slug variable. It should not be a big issue. Most importantly, this 'home'-appending issue it is not critical and it does not impact SEO. The home-added domain is not shown in the sitemap either. |
Using custom slugs if found through the translated markdowns of the pages hierarchy... this should lead to a better SEO for multilanguage websites