Skip to content
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

langswitcher.hreflang.html.twig displays incorrect urls when Grav is configured to generate absolute urls #77

Open
shauser67 opened this issue Feb 3, 2025 · 0 comments

Comments

@shauser67
Copy link

I have configure Grav to generate absolute urls (absolute_urls: true). In this case the template langswitcher.hreflang.html.twig displays incorrect urls with duplicate base (e.g. http://www.example.comhttp://www.example.com/en/example).

As a solution, uri.base should be added to the url only if absolute_urls is set to false:

{% if config.system.absolute_urls %}
    {% set href_url = lang_url ~ uri.params ~ (uri.query|length > 1 ? '?' ~ uri.query) %}
{% else %}
    {% set href_url = uri.base ~ lang_url ~ uri.params ~ (uri.query|length > 1 ? '?' ~ uri.query) %}
{% endif %}

Furthermore there is an error in line 12: config.languages.include_default_lang doesn't exist and should be replaced by config.system.languages.include_default_lang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant