You can get desktop, iOS, Android and Windows Phone favicon meta tags with the dato.site.favicon_meta_tags
helper:
# dato.config.rbdato.site.favicon_meta_tags# => [# { tag_name: "link", attributes: { sizes: "16x16", type: "image/png", rel: "icon", href: "https://www.datocms-assets.com/72/favicon.png?w=16&h=16" } },# { tag_name: "link", attributes: { sizes: "32x32", type: "image/png", rel: "icon", href: "https://www.datocms-assets.com/72/favicon.png?w=32&h=32" } },# { tag_name: "link", attributes: { sizes: "96x96", type: "image/png", rel: "icon", href: "https://www.datocms-assets.com/72/favicon.png?w=96&h=96" } },# { tag_name: "link", attributes: { sizes: "192x192", type: "image/png", rel: "icon", href: "https://www.datocms-assets.com/72/favicon.png?w=192&h=192" } },# { tag_name: "link", attributes: { sizes: "57x57", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=57&h=57" } },# { tag_name: "link", attributes: { sizes: "60x60", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=60&h=60" } },# { tag_name: "link", attributes: { sizes: "72x72", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=72&h=72" } },# { tag_name: "link", attributes: { sizes: "76x76", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=76&h=76" } },# { tag_name: "link", attributes: { sizes: "114x114", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=114&h=114" } },# { tag_name: "link", attributes: { sizes: "120x120", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=120&h=120" } },# { tag_name: "link", attributes: { sizes: "144x144", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=144&h=144" } },# { tag_name: "link", attributes: { sizes: "152x152", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=152&h=152" } },# { tag_name: "link", attributes: { sizes: "180x180", rel: "apple-touch-icon", href: "https://www.datocms-assets.com/72/favicon.png?w=180&h=180" } },# { tag_name: "meta", attributes: { name: "msapplication-square70x70logo", content: "https://www.datocms-assets.com/72/favicon.png?w=70&h=70" } },# { tag_name: "meta", attributes: { name: "msapplication-square150x150logo", content: "https://www.datocms-assets.com/72/favicon.png?w=150&h=150" } },# { tag_name: "meta", attributes: { name: "msapplication-square310x310logo", content: "https://www.datocms-assets.com/72/favicon.png?w=310&h=310" } },# { tag_name: "meta", attributes: { name: "msapplication-square310x150logo", content: "https://www.datocms-assets.com/72/favicon.png?w=310&h=150" } },# { tag_name: "meta", attributes: { name: "application-name", content: "Alban Bike Bags" } }# ]
In your dato.config.rb
file you can dump the meta tags in the frontmatter of your Jekyll posts or as data files:
# dato.config.rb# Create a YAML data file to store global data about the sitecreate_data_file("src/_data/settings.yml",:yaml,favicon_meta_tags: dato.site.favicon_meta_tags)# Dump all the blog postsdato.blog_posts.each do |article|directory "_posts" docreate_post "#{article.slug}.md" dofrontmatter(:yaml,title: article.title,seo_meta_tags: article.seo_meta_tags)content(article.content)endendend
And in your Jekyll views, transform the data into proper HTML tags:
<!DOCTYPE html><html><head><!-- ... -->{% for tag in site.data.settings.favicon_meta_tags %}{{ tag | tagify }}{% endfor %}{% for tag in page.seo_meta_tags %}{{ tag | tagify }}{% endfor %}</head><body><h1>{{ page.title }}</h1></body></html>
Where tagify
is a custom liquid filter you can put inside your project _plugins
directory:
# _plugins/tagify.rbmodule Jekyllmodule TagifyFilterdef tagify(input)name = input["tag_name"]content = input["content"]attributes = input.fetch("attributes", {}).map { |k, v| %Q(#{k}="#{CGI::escapeHTML(v)}") }if content.nil?"<#{[name, attributes].flatten.compact.join(' ')}>"else"<#{[name, attributes].flatten.compact.join(' ')}>#{content}</#{name}>"endendendendLiquid::Template.register_filter(Jekyll::TagifyFilter)