google sitemap生成器使用方法Word格式.docx
《google sitemap生成器使用方法Word格式.docx》由会员分享,可在线阅读,更多相关《google sitemap生成器使用方法Word格式.docx(73页珍藏版)》请在冰点文库上搜索。
Beforeyoubegin
TheGoogleSitemapGeneratorisaPythonscriptthatcreatesaSitemapforyoursiteusingtheSitemapProtocol.ThisscriptcancreateSitemapsfromURLlists,webserverdirectories,orfromaccesslogs.Inordertousethisscript:
∙Youmustbeabletoconnecttoandrunscriptsonyourwebserver.
∙YourwebservermusthavePython2.2orlaterinstalled.
∙YoumustknowthecommandthatlaunchesPython.(Generally,thisispython,butmayvarybyinstallation.Forinstance,ifthewebserverhastwoversionsofPythoninstalled,theearlierversionmaybeinvokedbythecommandpythonandthelaterversionmaybeinvokedbythecommandpython2.)
∙Youmustknowthedirectorypathtoyoursite.Ifyourwebserverhostsonesite,thismaybeapathsuchasvar/www/html.Ifyouhaveavirtualserverthathostsmultiplesites,thismaybeapathsuchashome/virtual/site1/fst/var/www/html.
∙Youmustbeabletouploadfilestoyourwebserver(forinstance,usingFTP).
∙IfyouwillbegeneratingalistofURLsbasedonaccesslogs,youmustknowtheencodingusedforthoselogsandthecompletepathtothem.
Ifyouaren'
tsureaboutanyofthis,youcancheckwithyourwebhostingcompany.
Nowyou’rereadytogetstarted.Here’sanoverviewofwhatyou’llneedtodo.
1.DownloadtheSitemapGeneratorprogramfiles.Extractthefilestoalocaldirectory.
2.Createaconfigurationfileforyoursiteusingtheprovidedexample_config.xmlfileasatemplate.Modifythisfileasneededforyoursiteandsaveit.
3.Uploadthenecessaryfilestoyourwebserver.
4.Runsitemap_gen.py.
5.AddthegeneratedSitemaptoyourGooglewebmastertoolsaccount.
6.Setuparecurringscript.(optional)
IfyouareunabletousetheSitemapGenerator,youcanaddaSitemaptoyourGooglewebmastertoolsaccountinanotherformat,suchasasimpletextfile.Third-partyprogramssupportingtheSitemapProtocol.
ForNewsSitemaps:
TheSitemapGeneratorisnotrecommendedforuseincreatingGoogleNewsSitemapsatthistime,duetothespecialrequirementsofNewsSitemaps.NewsSitemapsareintendedtobedynamiclistsofonlythemostrecentlypublishednewsarticles(ratherthantheentirewebsite),andtheyareupdatedfrequently.
1.DownloadingtheSitemapGeneratorprogramfiles
TheSitemapGeneratorfilesareavailableinZIPandGZarchiveformatsfromthefollowinglocation:
Onceyoudownloadthearchive,extractitintoalocaldirectory.Locatethefollowingfiles:
∙README—containsthelatestinformationaboutthistool
∙sitemap_gen.py—thepythonscriptthatgeneratesyourSitemap
∙example_config.xml—thetemplateconfigurationfileyou’llusetospecifytheconfigurationforyoursite
∙example_urllist.txt—thetemplateURLlistyoucanuseifyouwishtocreateaSitemapbasedonasetofURLsthatyouspecify
2a.Creatingaconfigurationfile
Thissectionprovidesstep-by-stepinstructionsforcreatingaconfigurationfile.Italsoprovidesacompletereferenceoftheoptionsavailable.IfyouarecreatingMobileSitemaps,seetheadditionalmobileguidelines.
Inordertocreateaconfigurationfileforyoursite,youmusthavethefollowinginformation:
∙ThebaseURLforyoursite(suchasEnsurethatyouincludetheprotocol(suchashttp:
//).Forinstance,isavalidbaseurl,butisnot.
∙ThewebserverpathtothelocationwhereyouwanttostoretheSitemap.Generally,thisisthepathtothebaseURLastheSitemapcannotcontainURLsthatareinahigher-leveldirectoryfromthelocationoftheSitemap.WhenyouruntheGoogleSitemapGenerator,itcreatestheSitemapandplacesitinthelocationyouspecify.
∙ThemethodsyouwanttheSitemapGeneratortousetocreateyourSitemap.Youcanuseanycombinationofmethods.Thefollowingmethodsareavailable:
oURL—listindividualURLsinthissectionoftheconfigurationfile,alongwithinformationabouteachURL.YouwouldgenerallyusethismethodinconjunctionwithanothermethodtomanuallyincludeadditionalURLsthatothermethodswouldn'
tpickup.
oURLlist—pointtheconfigurationfiletoatextfilethatcontainsalistofURLs.YoumightwanttousethismethodifthistextfilealreadyexistsorifyouuseascripttogeneratealistofURLs.
oDirectorypaths—specifythedirectorypathsforyoursiteandcorrespondingURLstothosepaths.TheSitemapGeneratorwillcreatealistofURLsbasedonthecontentsofthosedirectories.YoumightwanttousethismethodifyoursiteconsistsofstaticHTMLfiles.
oAccesslogs—pointtothepathtoyourlogfiles.TheSitemapGeneratorwillcreatealistofURLsbasedontheURLsincludedinthelogs.Youmightwanttousethismethodifyoursiteconsistsofdynamicpages.
oSitemap—pointtoexistingSitemapsthatyouhavecreatedwiththeSitemapGenerator.TheSitemapGeneratorwillcreateasingleSitemapthatincludestheURLscontainedineachSitemap.YoucouldusethismethodifyouhavealreadycreatedseveralsmallerSitemapsthatyouwanttocombineintoonelargerSitemap.
Createtheconfigurationfileasfollows:
1.Opentheexample_config.xmlfileinatexteditor.Saveitasanewfile(suchasconfig.xmlormysite_config.xml).
2.Locatethesitedefinitionsection:
3.<
site
4.base_url="
5.store_into="
/var/www/docroot/sitemap.xml.gz"
6.verbose="
1"
>
7.Changethebase_urlvaluetotheURLforyoursite.
8.Changethestore_intovaluetothepathonyourwebserverwhereyouwanttostoretheSitemapandthefilenameyouwanttousefortheSitemap.Generally,thisisthepathtothebaseURLsinceGooglecanonlyacceptURLsthatareatthesamelevelasorsubdirectoriesofthedirectorythatholdstheSitemap.Youcanspecifyarelativepathfromthedirectorywhereyouuploadthescriptoracompletepathfromtherootofyourwebserver.IfyouuploadthescripttoyourbaseURLdirectory,youcansimplyspecifythefilename.
9.Locatethegenerationmethodsectionsthatbeginwith**MODIFYorDELETE**.EachofthesesectionscorrespondstoamethodforgeneratingaSitemap.
10.Deletethesectionsforthemethodsyouaren’tgoingtouse.
11.Followtheinstructionsbelowforthemethodsyouaregoingtouse.
URL
Locatethefollowingsection:
<
!
--**MODIFYorDELETE**
"
url"
nodesspecifyindividualURLstoincludeinthemap.<
br>
Requiredattributes:
href-theURL
Optionalattributes:
lastmod-timestampoflastmodification(ISO8601format)
changefreq-howoftencontentatthisURLisusuallyupdated
priority-value0.0to1.0ofrelativeimportanceinyoursite
-->
urlhref="
/>
url
href="
lastmod="
2004-11-14T01:
00:
00-07:
00"
changefreq="
yearly"
priority="
0.3"
/>
Thissectiongivestwoexamples:
thefirstincludesonlytherequiredattributeandthesecondincludestherequiredattributeaswellastheoptionalattributes.
UsethisformatforeachoftheURLsyouwanttoinclude.ThechangefreqattributegivesGoogleageneralideaofhowoftentheURLisupdated.ThishelpsGoogleknowhowoftentovisitthepagefornewcontent.ThepriorityattributegivesGoogleinformationabouttherelativeimportanceofthispagecomparedtotheotherpagesofyoursite.ThisattributehasnoeffectonhowGooglecomparesyourpagetopagesonothersites,itjusthelpsGoogleknowwhichpagesofyoursitethatyouthinkaremostimportant.
URLlist
--**MODIFYorDELETE**
urllist"
nodesnametextfileswithlistsofURLs.
Anexamplefile"
example_urllist.txt"
isprovided.
path-pathtothefile
encoding-encodingofthefileifnotUS-ASCII
urllistpath="
encoding="
UTF-8"
UsethisformattopointtothepathandnameofthetextfilethatcontainsyourlistofURLs.Youcanusetheprovidedexample_urllist.txtfileasatemplateforthattextfile.Youcanspecifyeitherarelativeorcompletepathtoyourwebserver.Forinstance,iftheSitemapGeneratorandurlist.txtfilearelocatedinthesamedirectory,youcansimplyspecifythefilenameofthe.txtfile,IfyoucreateatextfilewithanencodingotherthanUTF-8,youcanusetheencodingattributetoindicatethisencoding.Ifyouhavemultiple.txtfiles,youcanusewildcards.Forinstance:
example_urllist*.txt"
ForeachURLyouincludeinthetextfile,youcanspecifythelastmodificationdate,changefrequency,andpriority.SeetheURLlisttextfilereferencesectionforcompleteinformationaboutthestructureofthisfile.
Directorypaths
directory"
nodestellthescripttowalkthefilesystemand
includeallfilesanddirectoriesintheSitemap.
path-pathtobeginwalkingfrom
url-URLequivalentofthatpath
default_file-nameoftheindexordefaultfilefordirectoryURLs
<
directorypath="
/var/www/icons"
url="
directory
path="
/var/www/docroot"
default_file="
index.html"