alchemy_cms icon indicating copy to clipboard operation
alchemy_cms copied to clipboard

sitemap generation for multi-language websites does not write out correct urls

Open rickythefox opened this issue 3 years ago • 0 comments

Steps to reproduce

  1. Create a multi-language website, let's say the default language is fr and the alternative language is en.
  2. Create a few pages in each website.
  3. In config/initializers/locale.rb set I18n.default_locale = :fr
  4. Check /sitemap.xml
  5. In config/initializers/locale.rb set I18n.default_locale = :en
  6. Check /sitemap.xml

Expected behavior

Links for the non-default language should be prefixed with the correct language, /en/ or /fr/. The sitemaps should not depend on the setting in locale.rb.

Actual behavior

Depending on the setting in locale.rb no links are prefixed, sitemap points to non-existing pages.

Proposed solution

I think helpers/alchemy/url_helper.rb:28 should call prefix_locale?(page.language_code) instead of just prefix_locale?. Otherwise it ends up using Language.current&.code.

System configuration

  • Alchemy Version: 2.0.5
  • Rails Version: 6.0.0

rickythefox avatar Jun 17 '22 13:06 rickythefox