Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 24, 2019 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/3e6116b59d587556aedb70bceeeff3c1 to your computer and use it in GitHub Desktop.
Save parzibyte/3e6116b59d587556aedb70bceeeff3c1 to your computer and use it in GitHub Desktop.
<?php
/**
* Generar un sitemap con PHP y Sitemap.php
*
* @author parzibyte
*/
# Incluye clase, o autoloader
include_once "Sitemap.php";
# Indica que vas a usar el namespace
use SitemapPHP\Sitemap;
# Crear sitemap
$sitemap = new Sitemap("https://parzibyte.me");
# Agrega todas las URL
$sitemap->addItem("/", "1.0", "yearly", "Today");
$sitemap->addItem("/blog", "0.9", "daily", "Today");
$sitemap->addItem("/apps/cotizaciones", "0.9", "daily", "Today");
# Genera el sitemap
$sitemap->createSitemapIndex("https://parzibyte.me/", "Today");
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://parzibyte.me/sitemap.xml</loc>
<lastmod>2019-03-23</lastmod>
</sitemap>
</sitemapindex>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://parzibyte.me/</loc>
<priority>1.0</priority>
<changefreq>yearly</changefreq>
<lastmod>2019-03-23</lastmod>
</url>
<url>
<loc>https://parzibyte.me/blog</loc>
<priority>0.9</priority>
<changefreq>daily</changefreq>
<lastmod>2019-03-23</lastmod>
</url>
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment