-
Notifications
You must be signed in to change notification settings - Fork 280
Open
Description
Hello,
I have been successfully using meta-tags to handle i18n in the sense that for a given page, my application controller knows the locale and displays it in the right language. So are my meta tags.
Here is a simple example of my PagesController:
class PagesController < ApplicationController
def home
set_meta_tags(
title: _("Home"),
description: _("This is my Home description."),
image_src: request.base_url + ActionController::Base.helpers.image_path(_("og_image_en.png")),
index: true,
og: {
type: "website",
url: request.original_url,
title: _("My website"),
description: _("This is my Home description."),
image: request.base_url + ActionController::Base.helpers.image_path(_("og_image_en.png"))
}
)
end
endMy home page is routed via /, but also, I handle my locales via the URL this way: https://mydomain.com/fr. Here is how my router works:
Rails.application.routes.draw do
scope "(/:locale)", locale: /#{I18n.available_locales.join('|')}/ do
root to: "pages#home"
end
endmetatags work well in all languages forhttps://mydomain.com/- they don't work for
https://mydomain.com/:locale, even if that is the same page
Any recommendation would help, thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels