getgrav / grav-plugin-langswitcher

Grav LangSwitcher Plugin
https://getgrav.org
MIT License
28 stars 26 forks source link

Two URLs for additional laguage using slug #65

Closed Sogl closed 2 years ago

Sogl commented 2 years ago

Don't know where exactly put this issue, let it be here.

I have site with default ru language and additional pl language. All folder names (URLs) based on ru title transliteration.

For example, I have 02.metodologiya folder, http://sitename.com/ru/metodologiya as result URL. pl version have slug: metodyka and http://sitename.com/pl/metodyka URL.

When I use default language (http://sitename.com/ru/metodologiya) and switch it to pl from langswitcher menu, my URL not changed to slug, only lang (http://sitename.com/pl/metodologiya). But when I use pl lang (http://sitename.com/pl/metodyka) and switch it to ru, all works fine (http://sitename.com/ru/metodologiya).

As result, I have two URLs for second language:

  1. http://sitename.com/pl/metodologiya
  2. http://sitename.com/pl/metodyka

I think it's not good for SEO.

How to change this behavior? Maybe there is some option in the Admin panel?

rhukster commented 2 years ago

This should be fixed in the latest version.

Sogl commented 2 years ago

@rhukster The same problem in latest langswitcher. Grav and plugins are up to date.

godfatherjohn commented 2 years ago

@Sogl -- AFAIK, this issue does not impact SEO. http://sitename.com/pl/metodyka is available for trackers and listed in the sitemap. http://sitename.com/pl/metodologiya is not listed in the sitemap and, I believe, only generated on the fly upon clicking PL in the Langswitcher section where you have RU PL.

Also, for SEO, it is generally useful to set the canonical link in the page's frontmatter, i.e.:

routes:
  canonical: '/pl/metodyka'

I understand that it would be better to have a flawlessly working Langswitcher, but until the issue is fixed the workaround ensures that the SEO setup of your site is adequate.

Question: Is metodologiya your 'home' folder as in 01.metodologiya? If so, then this would partly answer your question.

rhukster commented 2 years ago

Please try the latest version of the 'develop' branch. I've rewritten this logic.

Sogl commented 2 years ago

@rhukster The same problem using latest 3.0.1 langswitcher.

rhukster commented 2 years ago

can you please put together a little test package for me? a user/config/system.yaml, plus a couple of pages that exhibit this behavior. I have tried to recreate your setup based on your description, and can't recreate the issue.

Sogl commented 2 years ago

@rhukster Here

RU URL: /ru/blog/naturalnye-chisla-muzyka-kalendar-i-astrologiya-pifagora PL URL: /pl/blog/liczby-naturalne-muzyka-kalendarz-i-astrologia-pitagorasa

rhukster commented 2 years ago

I started from a fresh grav install, copied over your user/pages/blog folder and system.yaml, then installed latest langswitcher. Changed theme to quark and loaded the site. As you can see in the video below, it's showing with the correct polish slug no matter what I do. I also added slugs for the blog.md level to make it clearer for myself (not being able to read either language).

https://user-images.githubusercontent.com/1084697/187743913-388589ee-d6f2-40dc-9539-dc82d5596ed5.mp4

Is this not what you are seeing? This is version 3.0.1 of langswitcher btw.

rhukster commented 2 years ago

BTW if you have overriden the langswitcher twig, that might be your problem, you need to use the updated version from this version of langswitcher.

Sogl commented 2 years ago

Is this not what you are seeing? This is version 3.0.1 of langswitcher btw.

I see my problem as before... In your video all works fine.

BTW if you have overriden the langswitcher twig, that might be your problem, you need to use the updated version from this version of langswitcher.

I don't see any langswitcher.yaml in my template (I use inherited Typhoon): image

Sogl commented 2 years ago

@rhukster Can I send you full site in zip? I'm only need your email

godfatherjohn commented 2 years ago

@Sogl -- for nailing down the error:

Have you set any site wide routes or redirects?

The langswitcher.html.twig should be located in /user/plugins/langswitcher/templates/partials.

If you have other langswitcher.html.twig in other folders, possibly /user/themes/YOUR-THEME/templates/*, then delete these. You would only need a copy of that file in there to preserve personal tweaks in the file when updating the plugin in the future.

Sogl commented 2 years ago

Have you set any site wide routes or redirects?

In production I only have http to https redirect (Secure (HTTPS) Admin option) + concrete URLs redirects (moved from old Wordpress to new Grav site). On my dev/localhost I use http, no redirects.

The langswitcher.html.twig should be located in /user/plugins/langswitcher/templates/partials

Just reinstalled langswitcher with the same result. All langswitcher templates is here: image

If you have other langswitcher.html.twig in other folders, possibly /user/themes/YOUR-THEME/templates/*, then delete these. You would only need a copy of that file in there to preserve personal tweaks in the file when updating the plugin in the future.

I use inherited Typhoon theme and don't have any typhoon/templates/* or my-theme/templates/* files like langswitcher.html.twig (checked twice).

Sogl commented 2 years ago

Checked in Quark theme and all works fine. So... it's Typhoon related issue according to dynamic creation of langs menu: https://github.com/getgrav/grav-premium-issues/issues/306

Closing here.