LoginSignup
2
0

More than 3 years have passed since last update.

Railsでfaviconを設定する手順

Last updated at Posted at 2020-12-20

<この記事について>
自作のアプリ製作中にfaviconをつけたいと思い、意外と簡単にできたので備忘録として投稿します!

[環境]
・Ruby 2.6.5
・Rails 6.0.0
・macOS

まずは、事前準備としてfavicon用の画像を準備しましょう!
準備については任意ですが、個人的には以下のサイトが手軽にできてオススメです。

・ファビコン favicon.icoを作ろう!(https://ao-system.net/favicon/)
・icons8 | アイコン無料ダウンロード(https://icons8.jp/icons/set/favicon)

① assets/assets/images配下にfavicon.icoファイルを設置

assets/assets/images/favicon.ico

② faviconを読み込むために、「app/views/layouts/application.html.erb」内に以下を記述
※headタグ内です!

<html>
  <head>
<!--(省略) -->

    <%= favicon_link_tag('favicon.ico') %>

<!--(省略) -->
  </head>

③ ローカルサーバーを再起動

$ bundle exec rails s

これで完了です!

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0