Salin dan Bagikan
Cara Membuat Sitemap XML untuk Website: Tutorial Lengkap - Tutorial lengkap cara membuat sitemap XML untuk website dengan berbagai platform termasuk WordPress, …

Cara Membuat Sitemap XML untuk Website: Tutorial Lengkap

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.

Artikel Terkait

Link Postingan : https://www.tirinfo.com/cara-membuat-sitemap-xml-website/

Hendra WIjaya
Tirinfo
2 minutes.
7 January 2026