#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Essential Guide to Adding Favicon and OG Tags

To add a favicon and Open Graph (OG) tags, you put a few small image files on your server and a handful of link and meta tags in the head of each page. The favicon is the icon in browser tabs and search results; OG tags control how your link looks when shared on WhatsApp, LinkedIn, Facebook, X and Slack.

This guide gives the minimal file set, the exact tags, the image sizes, and how to test previews and clear stale ones.

Building Strong Brand Recognition Through Strategic Implementation

Part 1: Favicons

The files you actually need

Older guides list twenty icon sizes. Modern browsers need far fewer. A practical set is:

FileSizeUsed by
favicon.ico32×32 (can contain 16×16 too)Older browsers, and tools that request /favicon.ico automatically
icon.svgScalableModern browsers; stays sharp at any size and can adapt to dark mode
apple-touch-icon.png180×180iPhone and iPad home-screen shortcuts
icon-192.png, icon-512.png192×192, 512×512Android home screen and installable web apps, via the manifest

The tags

Put these in the <head> of every page:

<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="/manifest.webmanifest">

The sizes="32x32" on the ICO helps browsers that support SVG to prefer the SVG. And the manifest file:

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

Dark mode in the SVG icon

An SVG favicon can include a media query so it changes colour when the browser uses a dark theme:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  <style>
    circle { fill: #1a56db; }
    @media (prefers-color-scheme: dark) { circle { fill: #8ab4f8; } }
  </style>
  <circle cx="16" cy="16" r="14"/>
</svg>

Favicons in Google Search

Google shows your favicon next to your site in mobile and desktop results. Its Search Central guidelines ask for a square image (it recommends larger than 48×48 pixels), a stable URL that Googlebot is allowed to crawl, and an icon that represents your brand. Changes can take time to appear because Google recrawls favicons on its own schedule.

Design tips

  • Use one simple shape or one letter; detailed logos turn into a blur at 16 pixels.
  • Check contrast on both light and dark browser tabs.
  • Keep a little padding for the Apple icon, because iOS rounds the corners.

Part 2: Open Graph tags

The Open Graph protocol was introduced by Facebook in 2010 and is now read by most platforms that build link previews. Without it, a platform guesses a title and picks a random image from the page, or shows no image at all.

The core tags

<meta property="og:type" content="article">
<meta property="og:title" content="How to Add a Favicon and OG Tags">
<meta property="og:description" content="The files, tags and image sizes you need.">
<meta property="og:url" content="https://example.com/blog/favicon-og-tags">
<meta property="og:image" content="https://example.com/img/favicon-og-1200x630.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Browser tab with a favicon next to a link preview card">
<meta property="og:site_name" content="Example">

X (Twitter) cards

X reads its own twitter: tags and falls back to OG tags for the title, description and image. Usually you only need one extra line to get the large image layout:

<meta name="twitter:card" content="summary_large_image">

Rules that prevent broken previews

  1. Use absolute URLs (with https://) for og:image and og:url. Relative paths often fail.
  2. Use a 1200×630 image (a 1.91:1 ratio). It displays well on Facebook, LinkedIn and X. Keep important text away from the edges, since some apps crop to a square.
  3. Keep the image file reasonably small (JPEG or PNG, ideally well under 1 MB). Some apps, including WhatsApp, may skip large images.
  4. Give each page its own tags. Copying the home page's title and image onto every article makes every share look the same.
  5. Render the tags in the HTML from the server. Preview crawlers generally do not run JavaScript, so tags added by a script after page load are usually ignored. If your pages are built from data with JavaScript (as in populating blog sections from JSON), generate the meta tags at build time.

Part 3: Test and refresh previews

  • Facebook Sharing Debugger shows what Facebook sees and lets you "Scrape Again" after changes.
  • LinkedIn Post Inspector does the same for LinkedIn and refreshes its cache.
  • Browser developer tools: view the page source (not the Elements panel) to confirm the tags are in the original HTML.

Platforms cache previews, sometimes for days. If you replace an image, also change its file name (for example og-v2.png) so caches do not keep the old one.

Quick checklist

  • favicon.ico, icon.svg, apple-touch-icon.png and the manifest icons exist and load without errors.
  • Every page has a unique og:title, og:description, og:url and og:image.
  • og:url matches the page's canonical URL.
  • Previews look right in the Facebook and LinkedIn tools and in a WhatsApp test message.

These tags sit alongside your normal SEO tags. For the rest of the head section, see the on-page SEO checklist for new websites and how to write SEO-friendly blogs. If you are just starting out with HTML, build your first website with HTML and CSS and learn the HTML5 features worth using.

Uncodemy's Full Stack Development course covers HTML, CSS, JavaScript and deployment, including the head tags every production site needs.

Placed Students

Our Clients

Partners

...