feabila
(Felipe)
November 5, 2020, 6:38pm
1
Hi! I have been searching ways to customize Meta Tags for Social Sharing.
Here is an example, so to context:
Title: ‘Macro’
First post: ‘Este tópico …’
What I was looking for was a way to perform og:title and twitter:title meta tags. This way I would like to customize texts like the title to 'Felipe on Discourse - Macro’
Thoughts: I think It’ll be some workaround over plugin, to customize app/views like _head.html.erb
Could you help me ?
Regards,
Falco
(Falco)
November 5, 2020, 6:48pm
2
This tags are set here in core Discourse:
def rtl?
["ar", "ur", "fa_IR", "he"].include? I18n.locale.to_s
end
def html_lang
SiteSetting.default_locale.sub("_", "-")
end
# Creates open graph and twitter card meta data
def crawlable_meta_data(opts = nil)
opts ||= {}
opts[:url] ||= "#{Discourse.base_url_no_prefix}#{request.fullpath}"
if opts[:image].blank?
twitter_summary_large_image_url = SiteSetting.site_twitter_summary_large_image_url
if twitter_summary_large_image_url.present?
opts[:twitter_summary_large_image] = twitter_summary_large_image_url
end
A plugin can change the behavior of it.
6 Likes
feabila
(Felipe)
November 5, 2020, 7:32pm
3
Yooooo! Thank you Falco! That’s it!
In plugin, I got through evaluation of ApplicationHelper, like (in case anyone needs):
after_initialize do
ApplicationHelper.class_eval do
def crawlable_meta_data(opts = nil)
...
Appreciate your help!
4 Likes