Developer & Network Tools

Favicons and Social Preview Images

Which icon files and Open Graph tags your site needs, how to size them and why an old preview keeps showing up.

Key takeaways

  • A compact icon set is an ICO file, an SVG icon, a 180-pixel Apple touch icon and larger PNGs listed in a web app manifest.
  • Open Graph tags such as og:title and og:image control most link previews.
  • Use absolute HTTPS addresses for preview images, and keep important content away from the edges.
  • Preview services cache what they fetched, so changing an image's file name is the reliable way to refresh it.
  • Preview crawlers often don't run JavaScript, so the tags need to be in the HTML your server sends.

A favicon is the small icon that represents your site in browser tabs, bookmarks and some search results. A social preview image is the larger picture that appears when someone shares your link in a chat or social feed. Both are set with a few lines in your page's <head> and a handful of image files.

You don't need dozens of sizes. A small set of icons plus correct Open Graph tags covers most situations. This guide shows what to make, how to link it and how to fix previews that refuse to update.

Where the small icon appears

Browsers show the favicon in tabs, bookmark lists, history and address suggestions. Phones use a larger icon when someone adds your site to the home screen. Search engines may show it next to results, under their own size and content rules.

Historically, browsers requested /favicon.ico at the root of a site without being told to. Many still do, so placing a file there prevents a stream of 404 errors in your logs.

Design for the smallest case. At 16 or 32 pixels, fine lines and words disappear. A single letter or simple shape with strong contrast stays recognizable. Check it against both light and dark tab bars.

The files to create

File Typical size Purpose
favicon.ico 32 x 32 (may include 16 x 16) Fallback and automatic requests
icon.svg Scalable Sharp icon in browsers that support SVG
apple-touch-icon.png 180 x 180 Apple home screen
icon-192.png 192 x 192 Web app manifest
icon-512.png 512 x 512 Web app manifest, splash screens

Then link them:

<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">

The manifest is a small JSON file:

{
  "name": "Example Site",
  "icons": [
    { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
    { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
  ]
}

Home screen icons are often clipped into circles or rounded squares. For Android, you can add a separate "maskable" icon with extra padding and mark it with "purpose": "maskable". Give the Apple icon a solid background, since transparency may be filled unpredictably.

An SVG icon can include a CSS media query so its colors adapt to dark mode in browsers that honor it. A favicon generator produces the raster sizes from one source image, and an SVG optimizer trims the vector file.

One logo, many places
Source artwork A simple, high-contrast square mark Shared links A wide preview image Search results Shown under the engine's rules Browser tab ICO or SVG at tiny sizes Home screen Touch and manifest icons Bookmarks The same favicon in lists Source artwork A simple, high-contrast square mark Browser tab ICO or SVG at tiny sizes Home screen Touch and manifest icons Bookmarks The same favicon in lists Search results Shown under the engine's rules Shared links A wide preview image

Add the icons step by step

  1. Prepare a square master image, ideally a vector drawing, with the mark filling most of the space.
  2. Export the PNG sizes in the table and create the ICO file. Look at the smallest version at actual size and simplify it if it turns to mush.
  3. Place the files at the root of your site, or in one folder you reference consistently.
  4. Add the link tags to the shared header template so every page gets them.
  5. Open each icon's address directly and confirm it returns the image, not your home page or an error page.
  6. Test in two browsers and on a phone by adding the site to the home screen.

Many content management systems and site builders handle this from a single upload, often called a "site icon". If yours does, use it and then view your page source to see which tags it produced. Adding a second, hand-written set can leave browsers picking the old one.

Check your server's content types too. SVG files should be served as image/svg+xml, and a manifest as application/manifest+json or another JSON type. A file served with the wrong type may be ignored, especially if your server tells browsers not to guess.

When you paste a link into a messaging app or social network, a server (or the app itself) fetches the page and reads its metadata. The Open Graph protocol, introduced by Facebook and widely adopted, is the common vocabulary.

<meta property="og:title" content="How to Repot a Houseplant">
<meta property="og:description" content="Step by step, with soil and pot advice.">
<meta property="og:image" content="https://example.com/img/repot-card.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="A potted fern beside a bag of soil">
<meta property="og:url" content="https://example.com/guides/repotting">
<meta property="og:type" content="article">
<meta name="twitter:card" content="summary_large_image">

The last tag belongs to the card system of X (formerly Twitter), which also reads many Open Graph values. If tags are missing, services guess from the page title, meta description and whatever images they find, with mixed results.

Each page should have its own title, description and, ideally, image. A site-wide default is a good fallback. For search listings, which are a separate matter, see titles and meta descriptions.

How a link preview gets built
Person sharing Preview service Your server Pastes a link 1 Requests the page 2 HTML with Open Graph tags 3 Requests the og:image file 4 Image data 5 Shows the card 6 The result is usually cached Person sharing Preview service Your server Pastes a link 1 Requests the page 2 HTML with Open Graph tags 3 Requests the og:image file 4 Image data 5 Shows the card 6 The result is usually cached

Size and design the preview image

A canvas of 1200 by 630 pixels, a ratio of about 1.91 to 1, is the widely used recommendation. Platforms crop differently, some to a square thumbnail, so keep the headline and logo near the center.

Use large type and little of it. The card is often shown small on a phone. Save photographs as JPEG and flat graphics with text as PNG. Some services don't accept newer formats or SVG for preview images, so stick with those two for compatibility.

Keep the file reasonably light. Crawlers may give up on very large or slow images. The advice on preparing web images applies, and an Open Graph image generator can create a card from a title.

Write meaningful alternative text for og:image:alt. It helps people using screen readers where the platform passes it through.

Why a preview is wrong or missing

Check these in order.

  1. The tags are added by JavaScript. Many preview fetchers read only the initial HTML. Render the tags on the server or at build time.
  2. The image address is relative. Use a full https:// URL.
  3. The crawler is blocked. A login wall, a firewall rule, bot protection or a robots.txt entry may stop it. Check your server logs for its request and the status it received.
  4. Redirects lose the way. Long redirect chains or a redirect to a generic page produce the wrong card.
  5. The cache is stale. The service saved an earlier version.

You can see what a fetcher receives with:

curl -sL https://example.com/guides/repotting | grep -i "og:"

On Windows PowerShell, use curl.exe and pipe to findstr /i "og:".

Refresh a cached preview

Several large platforms provide a debugging or inspector page where you can enter a URL, see the parsed tags and request a new fetch. The names and sign-in requirements change, so search the platform's developer documentation. Some messaging apps offer no refresh at all.

The dependable method is to give the new image a new address, such as repot-card-v2.jpg, and update the tag. Adding a version query string often works too. Messages already sent usually keep the old card.

Favicons are cached stubbornly as well. Test in a private window, or load the icon file directly and reload it. If your CDN holds the old file, purge it or change the name, as explained in cache invalidation.

Mind privacy and private pages

Preview fetching has a side effect worth knowing. When someone pastes a private link into a chat, a service may request that address. Pages protected by a sign-in will show only the login page's tags, which is usually what you want. Pages protected only by a long, secret URL may be fetched, and their title and image shown to everyone in the conversation.

So keep sensitive details out of titles, descriptions and preview images on such pages. Don't let a plain visit to a link perform an action, such as confirming an order or unsubscribing an address, because an automated fetch would trigger it. Require a button press that sends a separate request. Advice on sharing with links applies here as well.

Common questions

Do I still need to supply many Apple icon sizes?

Generally no. A single 180-pixel touch icon is scaled down as needed.

Does a favicon improve search ranking?

Treat it as a recognition aid. It may help people pick your result out of a list, but don't expect a ranking change from adding one.

Can the preview image differ from images on the page?

Yes. Purpose-made cards with a readable title often work better than a cropped photo. Just make sure the image honestly represents the page.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Developer & Network Tools →

Latest news on this topic