metaタグを下記を参考に設定中!!
meta-tagsでRailsアプリのmetaタグとOGP設定
個別ビューの画像変更方法と画像の置き場所がわからない
上記のサイトには、
app/views/users/index.html.erb
<% assign_meta_tags title: 'ユーザーのリスト', description: 'ユーザーのリストです', keywords: 'ユーザー,リスト' %>
という設定があります。ここまではわかります。
画像設定時の書き方は??
*****の書き方がわからない。
画像はどこに置けばいいか。
<% assign_meta_tags image: ****** %>
image_tag
なのかimage_url
それともファイル名だけか...。
色々試してるのですが、なかなかうまくいきません。
画像以外は変更を確認できています。
コード(サイトより引用)
application.html.erb
<!DOCTYPE html> <html> <head> // ... <%= show_meta_tags %> </head> // ...
***.html.erb
<% assign_meta_tags title: 'ユーザーのリスト', description: 'ユーザーのリストです', keywords: 'ユーザー,リスト' %>
application_helper.rb
module ApplicationHelper def show_meta_tags if display_meta_tags.blank? assign_meta_tags end display_meta_tags end def assign_meta_tags(options = {}) defaults = t('meta_tags.defaults') options.reverse_merge!(defaults) site = options[:site] title = options[:title] description = options[:description] keywords = options[:keywords] image = options[:image].presence || image_url('image.png') configs = { separator: '|', reverse: true, site: site, title: title, description: description, keywords: keywords, canonical: request.original_url, og: { type: 'article', title: title.presence || site, description: description, url: request.original_url, image: image, site_name: site }, fb: { app_id: '*****' }, twitter: { site: '@twitter_account', card: 'summary', } } set_meta_tags(configs) end end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/09/07 01:42
2017/09/07 02:13