导航

杭州网站建设专家-兆合信息

兆合信息技术 构建品质网站

« Google搜索引擎优化技术的12个要点防范MSSQL数据库被挂马插入JS/sql注入的解决方法 »

如何制作sitemap (google sitemap制作)

如何制作sitemap:
1.进入网站 http://www.sitemapspal.com/

2.输入您的网站地址,如 http://www.hzzhit.com


3、回车后,第一屏页面下方的文本框中,会生成一段代码。用鼠标全部选中文本框中的代码,打开记事本等工具,复制上去。然后,把这个文件保存为:Sitemap.xml.
代码位置;见下图

4、把报存的Sitemap.xml文件上传到你的站点的根目录(比如:www)下。比如我的上传地址为:www.hzzhit.com 
是我最新提交的。通过本例可以看出,google 一个帐户可以同时提交多个网站的sitemaps )
还没完。在上图中www.hzzhit.com后面 “确认”。这说明这个网站地图还没有被GOOGLE确认。确认的好处是google会提供一些关于该站的访问统计信息。否则,只能起到一个提交网站更新信息的作用。如何让google确认呢? 直接点击这个“确认”的文字链接。会转到下一个页面。
10、google的原文说明如下,三个步骤让google确认A. 创建一个确认文件 创建名为 google9aeacbcb731ae23d.html 的空文件。此文件使 Google 可以对您进行唯一确认。您可以在任何文本编辑器中创建此文件。您可以在 此处阅读此文件的详细信息。 B. 上传确认文件
确认文件创建后,请将其置于您服务上的网站的根位置。 C. 请单击页面下方的的“确认”按钮
11、好了,经过确认的网站,在刚才的页面上“确认”按钮的前面会出现绿色“已确认”字样。表明确认成功。
现在你就可以尝试点击你关心的链接察看了网站的统计信息了。
google的行动够快的,25分钟就下载到了我的sitemap.赞一个呵呵

 

直接生成XML的Google SiteMap代码[ASP版本]


根据森林提供的代码修改完成
在GG已经通过

ASP版本,需要空间的FSO支持

<%
Server.ScriptTimeout=50000
' sitemap_gen.asp
' A simple script to automatically produce sitemaps for a webserver, in the Google Sitemap Protocol (GSP)
' by Francesco Passantino
' www.iteam5.net/francesco/sitemap
' v0.2 released 5 june 2005 (Listing a directory tree recursively improvement)
'
' BSD 2.0 license,
' http://www.opensource.org/licenses/bsd-license.php
' 收集整理:        重庆森林@im286.com


session("server")="http://192.168.0.111"                '你的域名
vDir = "/"                                               '制作SiteMap的目录,相对目录(相对于根目录而言)


set objfso = CreateObject("Scripting.FileSystemObject")
root = Server.MapPath(vDir)

'response.ContentType = "text/xml"
'response.write "<?xml version='1.0' encoding='UTF-8'?>"
'response.write "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>;"

str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf
str = str & "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>;" & vbcrlf

Set objFolder = objFSO.GetFolder(root)
'response.write getfilelink(objFolder.Path,objFolder.dateLastModified)
Set colFiles = objFolder.Files
For Each objFile In colFiles
        'response.write getfilelink(objFile.Path,objfile.dateLastModified)
        str = str & getfilelink(objFile.Path,objfile.dateLastModified) & vbcrlf
Next
ShowSubFolders(objFolder)

'response.write "</urlset>"
str = str & "</urlset>" & vbcrlf
set fso = nothing

Set objStream = Server.CreateObject("ADODB.Stream")
    With objStream
    '.Type = adTypeText
    '.Mode = adModeReadWrite
    .Open
    .Charset = "utf-8"
    .Position = objStream.Size
    .WriteText=str
    .SaveToFile server.mappath("/sitemap.xml"),2 '生成的XML文件名
    .Close
    End With

  Set objStream = Nothing
  If Not Err Then
    Response.Write("<script>alert('成功生成站点地图!');history.back();</script>")
    Response.End
  End If

Sub ShowSubFolders(objFolder)
        Set colFolders = objFolder.SubFolders
        For Each objSubFolder In colFolders
                if folderpermission(objSubFolder.Path) then
                        'response.write getfilelink(objSubFolder.Path,objSubFolder.dateLastModified)
                        str = str & getfilelink(objSubFolder.Path,objSubFolder.dateLastModified) & vbcrlf
                        Set colFiles = objSubFolder.Files
                        For Each objFile In colFiles
                                'response.write getfilelink(objFile.Path,objFile.dateLastModified)
                                str = str & getfilelink(objFile.Path,objFile.dateLastModified) & vbcrlf
                        Next
                        ShowSubFolders(objSubFolder)
                end if
        Next
End Sub


Function getfilelink(file,datafile)
        file=replace(file,root,"")
        file=replace(file,"\","/")
        If FileExtensionIsBad(file) then Exit Function
        if month(datafile)<10 then filedatem="0"
        if day(datafile)<10 then filedated="0"
        filedate=year(datafile)&"-"&filedatem&month(datafile)&"-"&filedated&day(datafile)
        getfilelink = "<url><loc>"&server.htmlencode(session("server")&vDir&file)&"</loc><lastmod>"&filedate&"</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>"
        Response.Flush
End Function


Function Folderpermission(pathName)

        '需要过滤的目录(不列在SiteMap里面)
        PathExclusion=Array("\temp","\_vti_cnf","_vti_pvt","_vti_log","cgi-bin","\admin","\edu")
        Folderpermission =True
        for each PathExcluded in PathExclusion
                if instr(ucase(pathName),ucase(PathExcluded))>0 then
                        Folderpermission = False
                        exit for
                end if
        next
End Function


Function FileExtensionIsBad(sFileName)
        Dim sFileExtension, bFileExtensionIsValid, sFileExt
        'modify for your file extension (http://www.googleguide.com/file_type.html)
        Extensions = Array("png","gif","jpg","jpeg","zip","pdf","ps","html","htm","php","wk1","wk2","wk3","wk4","wk5","wki","wks","wku","lwp","mw","xls","ppt","doc","swf","wks","wps","wdb","wri","rtf","ans","txt")
'设置列表的文件名,扩展名不在其中的话SiteMap则不会收录该扩展名的文件

        if len(trim(sFileName)) = 0 then
                FileExtensionIsBad = true
                Exit Function
        end if

        sFileExtension = right(sFileName, len(sFileName) - instrrev(sFileName, "."))
        bFileExtensionIsValid = false        'assume extension is bad
        for each sFileExt in extensions
                if ucase(sFileExt) = ucase(sFileExtension) then
                        bFileExtensionIsValid = True
                        exit for
                end if
        next
        FileExtensionIsBad = not bFileExtensionIsValid
End Function
%>

  
附录:

1、Google SiteMap官方生成器(Python 脚本)

https://www.google.com/webmasters/sitemaps/docs/zh_CN/sitemap-generator.html

2、Google Sitemap生成器(ASP.NET版本)

下载地址:http://sitemap.chinookwebs.com/

3、Google Sitemap生成器(phpBB 2.0.x版本)

国外发布了专门用于PHPBB 2.0.x 的 Google Sitemaps 生成器,他可以列出论坛的基本URLs, 单个论坛的URLs, 以及论坛主题的URLs等。如果你使用PHPBB, 这个很值得一试。

PHPBB SItemaps 生成器地址:http://www.phpbb.com/phpBB/viewtopic.php?t=295493

4、Google Sitemap生成器(php版本)

国外不少人已经做出了PHP版的 Google Sitemaps 生成器,这里介绍两个。
第一个是 phpSitemap 1.1, 上传版本。功能能上目前只能列出目录一级,还不能列出数据库产生的动态网页链接。像本站只能列出大概20个主要页面。下载后上传到网站根目录,运行phpsitemap.php即可。

下载地址:http://enarion.net/google/

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论及回复

最近发表

Powered By HZZHIT

Copyright 2008-2009 杭州兆合信息技术有限公司. All Rights Reserved.