ActionView::Helpers::AssetTagHelper

favicon_link_tag

API docs (Rails 8.1.4.1) ↗
def favicon_link_tag(source = "favicon.ico", options = {})

Description

Creates a favicon <link>.

Arguments

Changing a value updates the ERB and HTML.

Used as the href attribute. Depending on the value:
  • A URL (a string starting with https:// or another …://, //, data: or cid:): used as is.
  • A string starting with / ("/icon.svg"): used as is.
  • Any other string ("logo.png"): looks up the asset (a file in app/assets) and uses its path, with a digest added to the file name. If the asset is not found, raises Propshaft::MissingAssetError. The lookup and digest come from Propshaft; in an app without an asset pipeline, it just prepends /images/ to the path.
options= {}
"apple-touch-icon"
Sets the rel attribute instead of the default icon.
"image/png"
Sets the type attribute instead of the default image/x-icon. The type is not inferred from the extension, so a PNG or SVG still gets image/x-icon unless this option is given.
true skips the asset lookup and prepends /images/ to the path.
Common options

Rails handles these options the same way in every helper. Options the HTML spec does not allow on the <link>, and ones this site considers rarely used, are not listed here.

Shared by all helpers

{active: true, hidden: false}
A hash gives the keys whose values are not false or nil, joined with spaces. An array gives its elements joined with spaces, after removing nil, false and empty strings (including whitespace-only strings).
{controller: "tags", tags_suggestions_value: ["ruby", "rails"]}
A hash adds data-* attributes, with _ in the keys converted to -. Array and hash values are converted to JSON strings.
{describedby: ["name_help", "name_error"], invalid: false}
Like :data, adds aria-* attributes. Array values are joined with spaces, leaving out nil and empty strings (nothing is added if none remain). For a hash value, the keys whose values are not false or nil are joined with spaces.
Any other options become HTML attributes of the <link>; those with a nil value are left out. rel="icon" and type="image/x-icon" are added by default.

ERB

Changes from the previous output: Added Removed Changed


          

HTML