Lewati ke konten
Kembali ke Blog

Cara Membuat Sitemap XML untuk Website: Tutorial Lengkap

Β· Β· 4 menit baca

Sitemap XML adalah file yang berisi daftar semua URL di website Anda, membantu search engine menemukan dan mengindex content lebih efisien.

Apa itu Sitemap XML?

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-01-07</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://example.com/about</loc>
    <lastmod>2026-01-01</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.8</priority>
  </url>
</urlset>

Kenapa Sitemap Penting?

Benefits:
βœ“ Faster indexing of new pages
βœ“ Better crawl efficiency
βœ“ Helps with large websites
βœ“ Shows page importance
βœ“ Include lastmod for freshness

Cara Membuat Sitemap

WordPress

Opsi 1: Yoast SEO
1. Install Yoast SEO
2. Go to Yoast SEO > Settings > Site Features
3. Enable XML Sitemaps
4. Sitemap URL: yoursite.com/sitemap_index.xml

Opsi 2: Rank Math
1. Install Rank Math
2. Go to Rank Math > Sitemap Settings
3. Enable sitemap modules
4. Configure inclusions/exclusions

Hugo

Hugo generates sitemap automatically:

# hugo.toml
[sitemap]
  changefreq = "weekly"
  filename = "sitemap.xml"
  priority = 0.5

Custom sitemap template:

<!-- layouts/sitemap.xml -->
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  {{- range .Data.Pages }}
  <url>
    <loc>{{ .Permalink }}</loc>
    {{- if not .Lastmod.IsZero }}
    <lastmod>{{ .Lastmod.Format "2006-01-02" }}</lastmod>
    {{- end }}
  </url>
  {{- end }}
</urlset>

Manual/Custom Website

PHP script:

<?php
header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
$urls = [
    ['loc' => 'https://example.com/', 'priority' => '1.0'],
    ['loc' => 'https://example.com/about', 'priority' => '0.8'],
    // Add more URLs
];

foreach ($urls as $url) { echo "<url>"; echo "<loc>{$url['loc']}</loc>"; echo "<priority>{$url['priority']}</priority>"; echo "</url>"; } ?> </urlset>

Node.js

const { SitemapStream, streamToPromise } = require('sitemap');
const { createWriteStream } = require('fs');

const links = [ { url: '/', changefreq: 'daily', priority: 1 }, { url: '/about', changefreq: 'monthly', priority: 0.8 }, ];

const stream = new SitemapStream({ hostname: 'https://example.com' }); links.forEach(link => stream.write(link)); stream.end();

streamToPromise(stream).then(data => { require('fs').writeFileSync('./public/sitemap.xml', data.toString()); });

Submit Sitemap ke Google

  1. Buka Google Search Console
  2. Go to Sitemaps (left menu)
  3. Enter sitemap URL: sitemap.xml
  4. Click Submit

Sitemap Best Practices

DO:
βœ“ Include only canonical URLs
βœ“ Update lastmod when content changes
βœ“ Keep under 50,000 URLs per file
βœ“ Use sitemap index for large sites
βœ“ Submit to all search engines

DON'T: βœ— Include noindex pages βœ— Include redirected URLs βœ— Include duplicate URLs βœ— Fake lastmod dates βœ— Include low-quality pages

Sitemap Index (Large Sites)

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-posts.xml</loc>
    <lastmod>2026-01-07</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-pages.xml</loc>
    <lastmod>2026-01-01</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-products.xml</loc>
    <lastmod>2026-01-05</lastmod>
  </sitemap>
</sitemapindex>

Validasi Sitemap

Tools:
1. Google Search Console – Built-in validator
2. XML-Sitemaps.com – Online validator
3. Screaming Frog – Generate & validate

Kesimpulan

Sitemap XML adalah technical SEO fundamental yang membantu search engines menemukan dan mengindex content Anda lebih efisien. Pastikan sitemap selalu up-to-date dan disubmit ke Google Search Console.

Ditulis oleh

Hendra Wijaya

Tinggalkan Komentar

Email tidak akan ditampilkan.