如果您运行任何类型的网站,您可能应该有一个XML站点地图。它将帮助您的搜索引擎优化(help your search engine optimization)(SEO)。但是您可能想知道 XML 站点地图是什么,即使您知道,您将如何创建 XML 站点地图?
好消息是创建XML站点地图比准确理解它是什么更容易。理解XML站点地图也相当简单。你可以这样做。
什么是 XML 站点地图?(What Is An XML Sitemap?)
让我们首先介绍XML部分。XML代表 e X (L)tensible(X) Markup L语言(M)。它不完全是一种编程语言。这是一种灵活的方式来告诉 Web 浏览器和其他程序有关 XML 文档携带的数据的信息。
例如,我们可以告诉某人我们住在 123 Main Street,他们会理解的。但程序没有。
放置在地址数据两侧的 XML 标记将有助于告诉程序数据的含义。标签总是与一个开始标签<pre><StreetNumber></pre>和一个结束标签 <pre></StreetNumber></pre>。
所以我们可以使用XML标签来告诉程序该数据的含义。它可能看起来像:
<pre>
<StreetNumber>123</StreetNumber>
<StreetName>Main</StreetName>
<StreetType>Street</StreetType>
</pre>
对于识别这些标签的程序,它将知道这是一个完整的街道地址。然后程序可以使用该信息做一些有用的事情。
可扩展部分意味着这些标签可以是任何东西!如果程序理解标签
to mean street number, it would still work. So a developer could use just about anything to define the data between the XML tags.
在站点地图上。这几乎就是它听起来的样子。这是一张在我们的网站上可以找到不同类型信息的地图。
搜索(Search)引擎,如Google,需要特定信息,以便他们知道如何对我们的网站进行分类和排名。XML站点地图可以提供该信息。
这是单个网页的XML站点地图示例。
<pre>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</pre>
以下是这些标签的含义:
<pre><?xml version="1.0" encoding="UTF-8"?></pre>
这个告诉搜索引擎我们使用的XML版本是 1.0 并且文本是用(XML)UTF-8编码的。这是站点地图必须包含的编码规范。
<pre><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></pre>
这告诉搜索引擎在我们的站点地图中使用了什么站点地图标准。请记住(Remember),我们的 XML 必须使用与必须读取它才能理解它的程序相同的标签。
<pre><url></pre>
这告诉搜索引擎有关统一资源定位器(Uniform Resource Locator)( URL ) 的信息将跟随。URL也称为网址或链接。
<pre><loc>
这将标记中的数据定义为实际位置,或要编入索引的页面的特定URL。
<pre><lastmod></pre>
这个告诉搜索引擎该页面最后一次修改的时间。
<pre><changefreq></pre>
这让搜索引擎知道该页面的更改频率。可接受的值始终是每小时、每天、每周、每月、每年、从不。
<pre><priority></pre>
这告诉搜索引擎我们认为这个页面与我们站点地图中的其他页面相比有多重要。可接受的值范围为 0 到 1,其中 1 为最高值,0.5 为平均值。
请注意,这些不是搜索引擎的命令(commands for the search engine)。他们将阅读该信息并根据需要进行处理。
为什么要创建 XML 站点地图?(Why Create An XML Sitemap?)
一个制作精良的XML站点地图将帮助我们有最好的机会让我们的站点出现在我们希望看到的人面前。它会告诉搜索引擎我们提供什么样的信息,从哪里访问信息,以及信息的最后更新时间。
因为它是一张地图,所以它不必是景观的精确表示。我们可以选择其中的内容,以便搜索引擎获得正确的页面。例如,我们的隐私政策(Privacy Policy)和可接受使用(Acceptable Use)页面不会与网络上的任何其他网站有很大不同。与其映射这些,不如映射那些让用户找到好东西的页面,比如我们最好的博客文章或产品页面。
对于博客文章,我们可能需要一个站点地图,其中列出了您的所有文章,但对较新的文章给予更高的优先级。这向客户和搜索引擎表明我们的网站是新鲜的。
我们是否需要为图像创建站点地图?图片很重要。视觉是满足客户需求的第一件事。但是每个页面上都已经有了图片,并且这些图片将被编入索引。因此,只有图像的站点地图并不那么重要。
现在我们正在向搜索引擎展示我们网站的精髓。他们不需要浪费时间抓取和索引我们网站的大量必要但不那么重要的部分。
通过良好的站点地图,我们正在与搜索引擎合作,这将有助于我们的网站获得应有的最佳排名。
如何创建 XML 站点地图?(How Do I Create an XML Sitemap?)
幸运的是,有几个自动化工具可以帮助我们做到这一点。如果我们使用 WordPress(using WordPress),请获取Yoast SEO插件。这是一个很棒的搜索引擎优化工具,为我们创建站点地图只是它的功能之一。花时间真正学习如何使用 Yoast SEO 插件(learn how to use the Yoast SEO plugin)的所有功能。
用 Yoast 制作站点地图(Making a Sitemap With Yoast)
- 在我们的WordPress管理页面中,我们将安装Yoast SEO插件。安装后,我们将检查以确保XML 站点地图(XML Sitemaps )功能已启用。它应该是默认的。
- 单击(Click)左侧的Yoast SEO。然后单击功能(Features)选项卡。
- 向下滚动并确保XML 站点地图(XML Sitemaps)的滑块处于打开(On)位置。
- 从这里,我们可以看到站点地图的样子。单击(Click)XML 站点地图(XML Sitemaps)旁边的问号图标,然后单击链接查看 XML 站点地图(See the XML sitemap)。
- Yoast 将在网络浏览器中打开站点地图。它看起来不像我们之前看到的XML。没关系。
- 如果我们想查看XML,请右键单击此页面并选择查看源代码(View Source)。然后显示 XML。
这是使用Yoast SEO插件在WordPress中创建XML站点地图的最快方法。(XML)查看插件中的方法来完善站点地图并使其完全符合需要。
使用 Screaming Frog SEO 创建 XML 站点地图(Create an XML Sitemap With Screaming Frog SEO)
如果我们的网站不使用WordPress,我们可以使用各种在线和离线工具。
可能最常用的桌面 SEO 程序(most used desktop SEO program)是Screaming Frog SEO Spider。有免费和付费版本。要创建 XML 站点地图,我们只需要免费版本。
- 下载并安装后,打开程序。在我们可以创建XML站点地图之前,我们必须对站点进行爬网。抓取(Crawling)是在站点上逐页浏览并收集有关每个部分的数据的过程。
- 在顶部,我们会看到一个输入您网站URL的位置。(URL)去做。然后单击开始(Start )按钮。Screaming Frog将开始抓取该网站。
- 主窗口开始填充网站上事物的URL(URLs)。一旦屏幕右上角附近的进度条达到 100%,抓取就完成了。
- 在工具栏中,单击站点地图(Sitemaps),然后单击XML 站点地图(XML Sitemap)。站点地图导出配置(Sitemap Export Configuration )窗口将打开。
- 在站点地图导出配置(Sitemap Export Configuration)窗口中,我们可以调整站点地图的详细信息,例如changefreq、lastmod等。浏览标签以查看其中的内容。默认设置现在就可以了。单击下一步(Next)开始导出。
- 它会询问我们在哪里保存sitemap.xml文件。确保(Make)记住它的保存位置。我们需要将其上传到我们的网站才能使用。
保存后,将sitemap.xml文件上传到网站的根目录。现在我们可以向谷歌(Google)和其他搜索引擎注册站点地图。
如何让 Google 查看我的站点地图?(How Do I Get Google To See My Sitemap?)
我们说搜索引擎,但真正最担心的只有谷歌(Google)。那么我们如何让谷歌(Google)看到我们的站点地图呢?
我们希望它有助于让我们的网站排名更高,但只有在Google知道它的存在时才会有所帮助。我们需要使用Google Search Console。
How to Create an XML Sitemap for Your Site
If yoυ run a website of any kind, you should probably have an XML sitemap. It will help your search engine optimization (SEO). But you might be wondering what an XML sitemap is, and even if you knew, how would you create an XML sitemap?
The good news is that creating an XML sitemap is easier than understanding exactly what it is. And understanding XML sitemaps is fairly simple too. You can do this.
What Is An XML Sitemap?
Let’s cover the XML part first. XML stands for eXtensible Markup Language. It’s not exactly a programming language. It’s a flexible way to tell web browsers and other programs about the data an XML document carries.
For example, we could tell someone we live at 123 Main Street and they’d understand. But programs don’t.
XML tags placed on either side of the address data will help tell the program what the data means. Tags are always in pairs with one opening tag <pre><StreetNumber></pre> and one closing tag <pre></StreetNumber></pre>.
So we could use XML tags to tell programs what that data means. It might look like:
<pre>
<StreetNumber>123</StreetNumber>
<StreetName>Main</StreetName>
<StreetType>Street</StreetType>
</pre>
For a program that recognizes those tags, it will know that’s a full street address. Then the program can use that information to do something useful.
The extensible part means those tags could be anything! If the program understood the tag <pre><GlargleForp> to mean street number, it would still work. So a developer could use just about anything to define the data between the XML tags.
On to the sitemap. It’s pretty much what it sounds like. It’s a map of where to find different types of information on our website.
Search engines, like Google, want specific information so they know how to categorize and rank our site. The XML sitemap can provide that information.
This is an example of an XML sitemap for a single web page.
<pre>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</pre>
Here’s what those tags mean:
<pre><?xml version="1.0" encoding="UTF-8"?></pre>
This one tells the search engine that the XML version we’re using is 1.0 and the text is encoded in UTF-8. That’s the encoding specification that the sitemap must be in.
<pre><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></pre>
This tells the search engine what sitemap standard is being used in our sitemap. Remember, our XML has to be using the same tags as the program that has to read it for it to understand it.
<pre><url></pre>
This tells the search engine the information about a Uniform Resource Locator (URL) will be following. A URL is also known as a web address or link.
<pre><loc>
This defines the data in the tag as being the actual location, or specific URL of the page to be indexed.
<pre><lastmod></pre>
This one tells the search engine when that page was last modified.
<pre><changefreq></pre>
This lets the search engine know the change frequency of that page. Acceptable values are always hourly, daily, weekly, monthly, yearly, never.
<pre><priority></pre>
This tells the search engine how important we think this page is compared to other pages in our sitemap. Acceptable values range from 0 to 1, with 1 being the highest and 0.5 being average.
Note that these aren’t commands for the search engine. They’re going to read that information and process it however they want.
Why Create An XML Sitemap?
A well-made XML sitemap will help give us the best chance of getting our site in front of the people we want to see it. It will tell the search engine what kind of information we’re providing it, where to access the information, and when the information was last updated.
As it’s a map, it doesn’t have to be an exact representation of the landscape. We get to choose what goes in it, so the search engines get the right pages. For example, our Privacy Policy and Acceptable Use pages aren’t going to be very different from any other site on the web. Instead of mapping those, map the pages that get the user to the good stuff, like our best blog posts or product pages.
For the blog posts, we may want a sitemap that lists all your posts but gives a higher priority to more recent ones. That shows the customer, and the search engine, that our site is fresh.
Do we need to create a sitemap for the images? Pictures are important. The visual is the first thing that reaches the customer’s desires. But each page is already going to have the pictures on them, and those will get indexed. So having a sitemap just of images isn’t that important.
Now we’re presenting the essence of our site to the search engines. They don’t need to waste time crawling and indexing large necessary, but not as important, parts of our site.
With a good sitemap, we’re cooperating with the search engines and that will help our site get the best ranking it deserves.
How Do I Create an XML Sitemap?
Fortunately, there are several automated tools to help us do this. If we’re using WordPress, get the Yoast SEO plugin. It’s a great search engine optimization tool and creating a sitemap for us is just one of its features. Take the time to really learn how to use the Yoast SEO plugin for all its features.
Making a Sitemap With Yoast
- In our WordPress admin page, we’ll install the Yoast SEO plugin. Once installed, we’ll check to make sure that the XML Sitemaps feature is enabled. It should be by default.
- Click on Yoast SEO in the left side. Then click on the Features tab.
- Scroll down and ensure that XML Sitemaps has the slider in the On position.
- From here, we can see what the sitemap looks like. Click on the question mark icon next to XML Sitemaps and then click on the link See the XML sitemap.
- Yoast will open the sitemap in the web browser. It won’t look like the XML we looked at earlier. That’s alright.
- If we’d like to see the XML, right click on this page and select View Source. Then the XML is revealed.
That’s the quickest way to create an XML sitemap in WordPress with the Yoast SEO plugin. Take a look around in the plugin for ways to hone the sitemap and make it exactly as needed.
Create an XML Sitemap With Screaming Frog SEO
If we’re not using WordPress for our site, we can use a variety of online and offline tools.
Possibly the most used desktop SEO program is Screaming Frog SEO Spider. There’s a free and a paid version. For creating an XML sitemap, the free version is all we’ll need.
- Once it is downloaded and installed, open up the program. Before we can create an XML sitemap, we must crawl the site. Crawling is a process of going from page to page on a site and collecting data about each part.
- At the top, we see a spot to enter the URL of your website. Do that. Then click on the Start button. Screaming Frog will start crawling the site.
- The main window starts to fill with URLs of things on the site. Once the progress bar near the top right of the screen is at 100% the crawl is complete.
- In the toolbar, click on Sitemaps then XML Sitemap. The Sitemap Export Configuration window will open.
- The Sitemap Export Configuration window is where we can tweak the details of our sitemap, such as changefreq, lastmod, and others. Go through the tabs to see what’s there. The default settings will do for now. Click Next to begin the export.
- It will ask us where to save the sitemap.xml file. Make sure to remember where It’s saved. We’ll need to upload it to our website for it to be useful.
Once it is saved, upload the sitemap.xml file to the root of the website. Now we can register the sitemap with Google and other search engines.
How Do I Get Google To See My Sitemap?
We say search engines, but really the only one most are worried about is Google. So how do we get Google to see our sitemap?
We’re hoping that it’s helpful in getting our site ranked higher, but it will only help if Google knows it is there. We’ll need to use the Google Search Console.