Sitemap makes it easy for webmasters to inform search engines what pages are available for crawling on their sites. The simplest form of a Sitemap is an XML file that lists the URLs in your Web site and other metadata about each URL (when it was last updated, how often it was changed, and how important it is relative to other URLs on the site) so that the search engine can crawl the site more intelligently.
There are currently two types of formats
A. Google SiteMap
<urlset xmlns= "page list address" ><url><loc> URL </loc><lastmod>2005-06-03t04:20-08:00</ Lastmod><changefreq>always</changefreq><priority>1.0</priority></url><url ><loc> website </loc><lastmod>2005-06-02t20:20:36z</lastmod><changefreq>daily</ Changefreq><priority>0.8</priority></url></urlset>
Google SiteMapTwo. Baidu Sitemap
<?xml version= "1.0" encoding= "UTF-8"?><urlset><url><loc> Web address </loc><lastmod> 2010-01-01</lastmod><changefreq>daily</changefreq><priority>1.0</priority></ Url></urlset>
Baidu SitemapXML tag changefreq: page content update frequency. Lastmod: Page last modified on LOC: page permalink address priority: Precedence URL relative to other pages: parent tag relative to the first 4 tags urlset: parent tag relative to the first 5 tags I'll break down one sentence to explain each of the XML file tags: <urlset xmlns= "This line defines the namespace of this XML file, which is equivalent to the
Create a new text file paste in the code, and then save as a file in utf-8 format, the file name is Sitemap.xml, and then upload the file to the corresponding root directory of their own website;
2. To create a dynamic sitemap for a marketplace such as
Some East Www.jd.com/sitemap.xml
If you are a general mall, you can start with date.php (scheduled update page)
Shopnc
/**
* Generate Sitemap.xml file
* @return [Type] [description]
*/
function _create_sitemap () {
Home
$index = "<url>";
$index. = "<loc>". Shop_site_url. " </loc> ";
$index. = "<lastmod>". Date ("y-m-d"). " </lastmod> ";//Last Updated date
$index. = "<changefreq>always</changefreq>";//Update frequency selectable "always", "hourly", "Daily", "Weekly", "Monthly", " Yearly "
$index. = "<priority>1.0</priority>"; Priority this value is set between 0.0-1.0
$index. = "</url>";
Login Page
$index. = "<url>";
$index. = "<loc>". Shop_site_url. DS. " Index.php?act=login</loc> ";
$index. = "<lastmod>". Date ("y-m-d"). " </lastmod> ";//Last Updated date
$index. = "<changefreq>weekly</changefreq>";//Update frequency selectable "always", "hourly", "Daily", "Weekly", "Monthly", " Yearly "
$index. = "<priority>0.9</priority>"; Priority this value is set between 0.0-1.0
$index. = "</url>";
Registration page
$index. = "<url>";
$index. = "<loc>". Shop_site_url. DS. " Index.php?act=login&op=register</loc> ";
$index. = "<lastmod>". Date ("y-m-d"). " </lastmod> ";//Last Updated date
$index. = "<changefreq>weekly</changefreq>";//Update frequency selectable "always", "hourly", "Daily", "Weekly", "Monthly", " Yearly "
$index. = "<priority>0.9</priority>"; Priority this value is set between 0.0-1.0
$index. = "</url>";
//app download Page
$index. = "<url>";
$index. = "<loc>". Base_site_url. DS. " App/index.html</loc> ";
$index. = "<lastmod>". Date ("y-m-d"). " </lastmod>///Last Updated date
$index. = "<changefreq>weekly</changefreq>";//Update frequency optional "always", "hourly", "Daily", "Weekly", "Monthly", "yearly"
$index. = "<priority>0.9</priority>";//priority This value is set between 0.0-1.0
$i Ndex. = "</url>";
//Commodity classification
$goods _class = Model ("Goods_class")->getgoodsclasslist (Array ("Gc_show" =>1), "gc_id, Gc_name");
$GC = "";
foreach ($goods _class as $val) {
$GC. = "<url>";
$gc. = "<loc>". Urlshop ("Search", "index", Array (" cate_id "= $val [" gc_id "]))." </loc> ";
$GC. = "<lastmod>". Date ("y-m-d"). " </lastmod>///Last Updated date
$gc. = "<changefreq>weekly</changefreq>";//Update frequency optional "always", "hourly", " Daily "," Weekly "," Monthly "," yearly "
$gc. =" <priority>0.9</priority> ";//priority This value is set between 0.0-1.0
$GC. = "</url>";
}
Designer
$designer _list = Model ("designer")->getdesignerlist (Array ("Designer_status" =>1), "designer_id, Designer_name ");
$DL = "";
foreach ($designer _list as $val) {
$dl. = "<url>";
$dl. = "<loc>". Urldesigner ("designer", "index", Array ("d_id" and "= $val [" designer_id "])." </loc> ";
$dl. = "<lastmod>". Date ("y-m-d"). " </lastmod> ";//Last Updated date
$dl. = "<changefreq>weekly</changefreq>";//Update frequency selectable "always", "hourly", "Daily", "Weekly", "Monthly", " Yearly "
$dl. = "<priority>0.9</priority>"; Priority this value is set between 0.0-1.0
$dl. = "</url>";
}
Designer Information
$dnews _list = Model ("Dnews")->getarticlelist (Array (), 0);
$DN = "";
foreach ($dnews _list as $val) {
$dn. = "<url>";
$dn. = "<loc>". Urldnews ("Dnews", "detail", Array ("dnews_id" and "= $val [" dnews_id "]))." </loc> ";
$dn. = "<lastmod>". Date ("y-m-d"). " </lastmod> ";//Last Updated date
$dn. = "<changefreq>weekly</changefreq>";//Update frequency selectable "always", "hourly", "Daily", "Weekly", "Monthly", " Yearly "
$dn. = "<priority>0.9</priority>"; Priority this value is set between 0.0-1.0
$dn. = "</url>";
}
Product List
$goods _list = Model ("goods")->getgoodsonlinelist (Array (), "goods_id, Goods_name", 0, "goods_id desc", 5000);
$GL = "";
foreach ($goods _list as $val) {
$gl. = "<url>";
$gl. = "<loc>". Urlshop ("goods", "index", Array ("goods_id" and "= $val [" goods_id "])." </loc> ";
$gl. = "<lastmod>". Date ("y-m-d"). " </lastmod> ";//Last Updated date
$gl. = "<changefreq>daily</changefreq>";//Update frequency selectable "always", "hourly", "Daily", "Weekly", "Monthly", "yearly "
$gl. = "<priority>0.8</priority>"; Priority this value is set between 0.0-1.0
$gl. = "</url>";
}
$str = ' <?xml version= ' 1.0 "encoding=" Utf-8 "?>". " <urlset> ". $index. $gc. $dl. $dn. $gl." </urlset> ";
@file_put_contents (Base_root_path. DS. " Sitemap.xml ", $STR);
}
Sitemap.xml static and dynamic Generation page SHOPNC two times development dynamic generation Sitemap.xml