如果有很多条目,如何生成站点地图?

时间:2013-06-27 16:21:52

标签: php xml sitemap

我使用php创建了一个动态站点地图,您可以在此link

中查看我的站点地图

我要提交此链接到谷歌网站管理员工具,但我不知道这是正确的方式发布所有的网页地图在1页或可能使用分页为此?我不知道哪种方式是正确的但这个网站使500或每天600个用户,我认为它不是一个正确的方式ro在站点地图中插入所有这些...现在需要帮助

这是我创建此站点地图的代码

header("Content-type: text/xml");
$xml = new DomDocument('1.0', 'utf-8'); 
$xml->formatOutput = true; 

// creating base node
$urlset = $xml->createElement('urlset'); 
$urlset -> appendChild(
    new DomAttr('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')
);

    // appending it to document
$xml -> appendChild($urlset);

// building the xml document with your website content
foreach($content as $entry)
{

    //Creating single url node
    $url = $xml->createElement('url'); 

    //Filling node with entry info
    $url -> appendChild( $xml->createElement('loc', $entry['permalink']) ); 
    $url -> appendChild( $lastmod = $xml->createElement('lastmod', $entry['updated']) ); 
    $url -> appendChild( $changefreq = $xml->createElement('changefreq', 'monthly') ); 

    // append url to urlset node
    $urlset -> appendChild($url);

}

echo $xml->saveXML();
?>

1 个答案:

答案 0 :(得分:1)

Creating Sitemaps - Google Webmaster Tools

站点地图文件不得超过50,000个网址,未压缩时不得超过50MB。如果您的站点地图大于此值,请将其分成几个较小的站点地图。

如果您有多个Sitemap,可以在Sitemap index file中列出,然后将Sitemap索引文件提交给Google。