logo
  • Work
  • Accent
  • News
logo
  • Work
  • Accent
  • News
ShopifyJune 24, 2016

Add favicons for Shopify

By Ricky Cox

Last updated: 16 August, 2020

If you search the web looking for expert advice on favicons, you’ll likely find authoritative information that is often out-of-date (maybe even this article).

Let’s face it, nobody wants to waste their life thinking about favicons (especially me!). The current situation is a mess and it can only get worse as new devices are released, with no clear industry standards.

So while we don’t want to waste time, we do want the site to look good when we save a bookmark to the home screen. Thankfully there is an easy solution.

Generate favicons

First head over to Real Favicon Generator and generate your icons. Take care to check all the setting in each tab.

Upload assets

Upload the icons to the “assets” directory of your Shopify theme. Don’t upload the browserconfig.xml file and don’t change the file names.

You will also need to edit and upload the site.webmanifest.json file (shown below). I also added the file extension “.json”.


{
	"name": "Your Store Name",
	"short_name": "Your Store Name",
	"icons": [
		{
			"src": "assets\/android-chrome-192x192.png",
			"sizes": "192x192",
			"type": "image/png"
		},
		{
			"src": "assets\/android-chrome-512x512.png",
			"sizes": "512x512",
			"type": "image/png"
		}
	],
	"theme_color": "#ffffff",
	"background_color": "#ffffff",
	"start_url": "https://your-domain.com/",
	"display": "standalone"
}

Be sure to edit the snippet above and set the correct path for the Android assets. If you login to the Shopify admin, you can find the image files and copy the paths.

The end result should look something like this. Also be sure you change the theme_color to match your color scheme.


{
	"name": "Accent",
	"short_name": "Accent",
	"icons": [
		{
			"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/1158\/3098\/t\/4\/assets\/android-chrome-192x192.png?13373704242453535029",
			"sizes": "192x192",
			"type": "image/png"
		},
		{
			"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/1158\/3098\/t\/4\/assets\/android-chrome-512x512.png?13062946215459455012",
			"sizes": "512x512",
			"type": "image/png"
		}
	],
	"theme_color": "#00d1ae",
	"background_color": "#ffffff",
	"start_url": "https://accent-theme-1.myshopify.com",
	"display": "standalone"
}

 

Create config

Next create a file called browserconfig.xml.liquid and add the snippet below. Then upload that to your “assets” directory. Be sure you change the TileColor to match your color scheme.


<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
	<msapplication>
		<tile>
			<square150x150logo src="{{ 'mstile-150x150.png' | asset_url }}"/>
			<TileColor>#cc3300</TileColor>
		</tile>
	</msapplication>
</browserconfig>

 

Create snippet

In the “snippets” directory of your Shopify theme, create a file called favicons.liquid and add the snippet of code below. You will also need to change the color values for mask-icon and theme-color.


<!-- /snippets/favicons.liquid -->
<link rel="apple-touch-icon" sizes="180x180" href="{{ 'apple-touch-icon.png' | asset_url }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ 'favicon-32x32.png' | asset_url }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ 'favicon-16x16.png' | asset_url }}">
<link rel="manifest" href="{{ 'site.webmanifest.json' | asset_url }}">
<link rel="mask-icon" href="{{ 'safari-pinned-tab.svg' | asset_url }}" color="#cc3300">
<link rel="shortcut icon" href="{{ 'favicon.ico' | asset_url }}">
<meta name="apple-mobile-web-app-title" content="{{ shop.name }}">
<meta name="application-name" content="{{ shop.name }}">
<meta name="msapplication-TileColor" content="#cc3300">
<meta name="msapplication-config" content="{{ 'browserconfig.xml' | asset_url }}">
<meta name="theme-color" content="#cc3300">

 

Final step

Finally in your layout/theme.liquid file, add the following to the head section. You can also add it to these files if desired: layout/password.liquid and layout/gift_card.liquid


{% include 'favicons' %}

 

Testing

If you head back to the Real Favicon Generator site, you’ll notice that they have a form on the homepage for testing your site.

Update

The snippet above is a bit shorter than previously posted version. If you’re interested you can read more about it here: New favicon package – Less is more.

Next Storetasker

15 Comments

  • Art
    December 31, 2018 at 7:39 am
    Any chance you can see what the hell I am doing wrong? http://store.briancrower.com
    Log in to Reply
    • Ricky Cox
      January 2, 2019 at 6:09 pm
      There's some information here on "How to enable favicons in Safari" if your on iOS 12 device or newer.
  • Art
    January 8, 2019 at 3:35 am
    Hey did not realize you wrote me back sorry I was gone for the holidays as well. Check this out I loaded two screenshots up from my iphone. I saw your images on your phone and they looked great but for "bookmarks" for me, no good. Check it out. http://www.adaware.net/IMG_2419.jpg http://www.adaware.net/IMG_2418.PNG
    Log in to Reply
    • Ricky Cox
      January 8, 2019 at 2:03 pm
      Your browser might be storing an old version of the image. You could try clearing browser cache memory.
  • Yu DeChen
    January 22, 2020 at 6:17 pm
    Thank you for sharing this post! I have one question. In site.webmanifest.json, the src of each icon needs to be different on each theme? If I publish a new theme, the icon asset needs to be copied from theme assets again?
    Log in to Reply
    • Ricky Cox
      January 22, 2020 at 8:22 pm
      Yes that's correct. You need to copy the files across into the "assets" directory of the new theme and update the URLs in the site.webmanifest.json file. Alternatively you could upload those files to the "Settings/Files" section of Shopify admin. In which case the URL would always be the same.
  • Yu DeChen
    January 23, 2020 at 12:56 am
    "Alternatively you could upload those files to the "Settings/Files" section of Shopify admin" Aha, good idea. Thank you Ricky!
    Log in to Reply
  • Colton
    April 1, 2020 at 4:13 pm
    Hello I did everything per instructions mainly to be able to add to home screen on phone, thank you btw it worked, however my favicon for mobile is now changed it used to just be my logo but now it's the logo with a black squared background like I had to set up for the android part of favicon generator. Can you help me to get my mobile favicon back to how it was please? I may have put html color code (#000000) somewhere withing the themes code like towards the end of these directions in the snippet directory I shouldn't have? I'm not sure I just know my mobile favicon was fine the way it was i just wanted to be able to add favicon/logo to home screen of a phone and windows and whatnot. I want my mobile favicon exactly like my desktop favicon which is the way it was before. Please help asap. Thanks.
    Log in to Reply
    • Ricky Cox
      April 1, 2020 at 9:17 pm
      Hi Colton, try double-checking the settings in the Real favicon Generator. It gives you options and a preview for each platform. If that doesn't work, recheck the code and try changing the hex value.
  • Colton
    April 1, 2020 at 10:07 pm
    Thanks for the quick response. I did, It's displaying that the mobile favicon is as it should be, just like on desktop but unfortunately it's actually not. My mobile favicon was actually fine before this code edit considering the shopify favicon settings took care of desktop/mobile, just not the other platforms. The only favicons of mine that are supposed to have the black background are the 2 different sizes for android, which I chose to edit only cause samsung changed their setup in recent years to include mandatory rounded square backgrounds for all app icons rather than freeform which I preferred, otherwise I wouldn't even be using any black background for android except if I only used my "master image" it'd show up with a white background on newer updated phone's homescreens such as my s9+ anyways. I can show you screenshots of everything I'm referring to to help you better understand although I'm not entirely sure how to include them here. Nonetheless, I can't seem to find anything in this code that would cause my mobile favicon to be appearing as the android favs are considering the 32x32 fav uploaded to assets looks exactly the way it should... I'm pretty sure the code is how it should be.. I'm lost here.
    Log in to Reply
  • Colton
    April 1, 2020 at 10:18 pm
    I also meant to ask change the hex value by checking which part of the code? There's plenty of places within the code to change hex value but I'm not sure where. Theme color within the snippet directory? I can't imagine changing the color code for "mask icon" would do anything but mess with safari pinned tab not to mention tile color only affects windows... I'm not sure where to check or change anything.
    Log in to Reply
    • Ricky Cox
      May 7, 2020 at 9:28 pm
      Hi Colton, the code that was generated on the Real Favicon site should have the correct hex codes. Use that as a reference.
  • Megha
    May 14, 2020 at 8:42 pm
    Do we have to create file named site.webmanifest.json, or it is already present in Shopify theme and we just have to edit it? if we have to v=create and upload, then in which section ? Like assets, or Snippets, or Locales,etc?
    Log in to Reply
    • Megha
      May 14, 2020 at 8:50 pm
      As you mentioned- I also added the file extension “.json”. please elaborate where you created this extension, how we create in our Shopify theme. also, adding this extra step as compared to the previous blog- what this .json file is adding more in the process?
    • sph94
      June 24, 2020 at 11:50 pm
      I also cannot work this out. Where do we save the JSON file? It does not work by uploading it to the assets folder, the config folder does not allow new json files nor seemingly does the locales, and all the others only have .liquid files. Please help.

Leave a comment or Cancel Reply

You must be logged in to post a comment.

  • Suture

    • About
    • Services
    • Support
    • Contact
    • Terms & Conditions
    • Privacy Policy
  • Recent News

    • Storetasker January 16, 2019
    • Add favicons for Shopify June 24, 2016
  • Newsletter

    Subscribe for news and updates.

© Suture, 2024 | Hosting by Dreampress