Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
⚙️ Module B – Technical SEO & measurement (Days 5–7)  ·  Day 05

Day 5: Technical SEO – robots.txt, Sitemap, Canonical

⏱ 90 min📶 Intermediate🎯 100% self-study
Day 5 / 10

✅ Today you will learn

  • Control crawling with robots.txt
  • Help discovery with an XML sitemap
  • Avoid duplicates with canonical tags
  • Use noindex, 301 redirects and status codes correctly
  • Add hreflang and basic structured data

🏢 In the real world

The institute moved its site from http://www.sharmacomputers.example/tally-course.html to https://sharmacomputers.example/courses/tally/. Now Google sees four versions of the home page, old links show 404 errors, and the Hindi page competes with the English one. Technical SEO fixes all of this in a few lines.

robots.txt – what may be crawled

robots.txt sits at the root (/robots.txt) and tells crawlers which paths not to crawl. It is not a security tool and does not remove a page from Google – a blocked page can still appear if other sites link to it. To keep a page out of results, use noindex and let it be crawled.

robots.txt
User-agent: *
Disallow: /admin/
Disallow: /account/
Allow: /

Sitemap: https://sharmacomputers.example/sitemap.xml
⚠️ The one-line disaster

Disallow: / blocks the whole site. It is often left behind after development – check robots.txt after every launch.

XML sitemap – what should be found

A sitemap lists the URLs you want indexed (only canonical, indexable, 200-status pages). Submit it in Search Console (Day 7) and reference it in robots.txt. Keep lastmod honest – change it only when the content really changes.

XML
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://sharmacomputers.example/courses/tally/</loc>
    <lastmod>2026-10-20</lastmod>
  </url>
  <url>
    <loc>https://sharmacomputers.example/courses/python/</loc>
    <lastmod>2026-09-12</lastmod>
  </url>
</urlset>

Canonical, noindex and hreflang

ProblemFix
http://, https://, www and non-www versions of every page301-redirect all to one version (below) and set a self-referencing canonical
Same page with ?utm_source= or sorting parametersCanonical to the clean URL
Thank-you page, internal search results, loginnoindex (and no links in the sitemap)
English and Hindi versions of the same pagehreflang en/hi on both pages pointing to each other, plus x-default
HTML
<!-- the preferred URL of this page -->
<link rel="canonical" href="https://sharmacomputers.example/courses/tally/">

<!-- English and Hindi versions of the same page -->
<link rel="alternate" hreflang="en" href="https://sharmacomputers.example/courses/tally/">
<link rel="alternate" hreflang="hi" href="https://sharmacomputers.example/hi/courses/tally/">
<link rel="alternate" hreflang="x-default" href="https://sharmacomputers.example/courses/tally/">

<!-- keep a page out of Google (e.g. thank-you page) -->
<meta name="robots" content="noindex, follow">

Status codes and redirects

CodeMeaningSEO use
200OKNormal page
301Moved permanentlyPage moved for good – passes signals to the new URL
302 / 307Moved temporarilyShort-term moves only (e.g. a sale page)
404Not foundDeleted page with no replacement – fine if it is truly gone; redirect if there is a close replacement
410GonePermanently removed on purpose
5xxServer errorFix fast – repeated errors slow crawling
Apache .htaccess
# Force HTTPS and one host name (Apache .htaccess)
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://sharmacomputers.example%{REQUEST_URI} [L,R=301]

# Old URL moved permanently to the new one
Redirect 301 /tally-course.html /courses/tally/
💼 Office practice – professional tipBefore changing URLs, make a spreadsheet: old URL → new URL. Redirect every old URL to its closest new page (not all to the home page), update internal links, and re-submit the sitemap. Losing redirects in a migration is one of the most common causes of sudden traffic loss.

HTTPS and structured data

HTTPS is a must – browsers mark HTTP pages “Not secure” and it is a light ranking signal. Structured data (JSON-LD using schema.org) describes the page in a machine-readable way and can make it eligible for rich results. Add only what is true and visible on the page, and test it with Google’s Rich Results Test.

JSON-LD
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "EducationalOrganization",
  "name": "Sharma Computer Institute",
  "url": "https://sharmacomputers.example/",
  "logo": "https://sharmacomputers.example/images/logo.png",
  "telephone": "+91-00000-00000",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "Shop 4, Example Market",
    "addressLocality": "Aligarh",
    "addressRegion": "Uttar Pradesh",
    "postalCode": "202001",
    "addressCountry": "IN"
  }
}
</script>
ℹ️ Rich results change

Google decides which rich result types it shows. For example, FAQ and HowTo rich results are now shown only for very few sites. Check Google Search Central’s list of supported structured-data features before investing time.

Solved examples

Example 1: Diagnose the migration

SymptomCauseFix
Old /tally-course.html links show 404No redirect after URL changeRedirect 301 /tally-course.html /courses/tally/
Search Console: “Duplicate without user-selected canonical”http/https and www/non-www all liveForce one host with 301 + self canonical
New course pages not indexed after 3 weeksNot in sitemap and no internal linksAdd to sitemap, link from /courses/ and home page
Whole site vanished from Googlerobots.txt has Disallow: / left from stagingRemove it, then request indexing of key pages

Practice exercises (unsolved – answer hidden)

Try each exercise yourself first – on paper, in a text editor or on your own site – then open the answer to check.

🏋️ Practice – do it yourself

Task 1: Write a robots.txt that blocks /cart/ and /search/ for all crawlers, allows everything else, and points to https://sharmacomputers.example/sitemap.xml.
Show solution
robots.txt
User-agent: *
Disallow: /cart/
Disallow: /search/
Allow: /

Sitemap: https://sharmacomputers.example/sitemap.xml
Task 2: Which would you use – 301, 302, noindex or canonical? (a) course page moved forever (b) Diwali offer page for 10 days (c) printer-friendly copy of an article (d) “thank you for enquiring” page.
Show solution(a) 301 (b) 302 (temporary) (c) canonical to the main article (d) noindex.
Task 3: Your site has English pages and Hindi pages at /hi/… Write the hreflang tags for the Python course page.
Show solution
HTML
<link rel="alternate" hreflang="en" href="https://sharmacomputers.example/courses/python/">
<link rel="alternate" hreflang="hi" href="https://sharmacomputers.example/hi/courses/python/">
<link rel="alternate" hreflang="x-default" href="https://sharmacomputers.example/courses/python/">

Put the same set on both the English and the Hindi page.

🏅 Job skills unlocked today

✔ Write robots.txt and sitemaps✔ Use canonical, noindex and hreflang✔ Apply 301/302 and read status codes✔ Add and test structured data

Quick quiz

🧠 Quick Quiz – test yourself

1. robots.txt is used to:
It is not security and not de-indexing.
2. A page moved permanently needs a:
301 = permanent.
3. To keep a page out of Google results use:
noindex must be crawlable to be seen.
4. hreflang tells Google about:
e.g. en and hi versions.

Interview corner

💼 Interview Corner

What is the difference between robots.txt Disallow and noindex?

Disallow stops crawling but the URL can still be indexed from links; noindex lets Google crawl the page and tells it not to show it in results. To de-index, use noindex and do not block the page.

How do you handle a site migration?

Map every old URL to the closest new URL, implement 301 redirects, update internal links and canonicals, keep robots.txt open, submit the new sitemap, and monitor Search Console for 404s and coverage changes.

Summary

  • robots.txt controls crawling, not indexing.
  • Sitemap lists canonical, indexable URLs.
  • One version of every URL: 301 + canonical; hreflang for languages.
  • HTTPS always; structured data only for true, visible facts.
➡️ Next

Day 6: page speed, mobile-friendliness and Core Web Vitals (LCP, INP, CLS).

Frequently Asked Questions

Do I need structured data to rank?
No. It helps Google understand the page and may enable rich results, but good content and a crawlable site matter far more.
How often should the sitemap update?
Automatically whenever pages are added or changed. Most CMSs and site generators do this; otherwise regenerate it after each update.
← SEO in 10 Days
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicDay 6: Page Speed & Core Web Vitals Your progress: 5 / 10 (50%) · Lesson 6 / 10 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free