网站地图插件 XML Sitemap Generator for Google 使用指南

在搜索引擎优化(SEO)的世界里,一个结构清晰、实时更新的 Sitemap(网站地图)是让搜索引擎快速识别你网站结构的关键利器。不论你是 SEO 新手还是资深站长,拥有一个自动生成 XML 和 HTML 格式的网站地图都将极大提升你的网站收录率和排名表现。

XML Sitemap:面向搜索引擎,告诉 Google、Baidu、Bing 等搜索机器人你网站的结构、更新时间、页面优先级等信息。
HTML Sitemap:展示给用户查看的页面地图,提升网站的可用性和结构清晰度,尤其适用于大型内容网站。

XML Sitemap Generator for Google 是 WordPress 平台上的一个网站地图插件(原名 Google XML Sitemaps),用于自动生成符合搜索引擎标准的XML站点地图,帮助 Google、Bing 等搜索引擎抓取和索引网站内容。该插件占用资源更小,使用简单。由于它是根据 GPL 发布的,因此您可以在您的个人或商业网站上免费使用它。

插件地址

https://wordpress.org/plugins/google-sitemap-generator

使用指南

在 WordPress 后台安装插件界面直接搜索 XML Sitemap Generator for Google 安装即可,然后启用插件,点击插件右边的“设置”按钮进行详细设置,如下图。

网站地图插件Google XML Sitemaps详细使用设置图文教程

如果你已经自己上传了 robots.txt 文件,那么你就需要把这个勾去掉,如果没有上传 robots.txt 文件,你就需要把这个勾打上。

网站地图插件Google XML Sitemaps详细使用设置图文教程

PS:如果你已经在网站根目录下上传了 robots.txt 文件,那么只需要打开 robots.txt 文件添加 sitemap 链接地址即可,如下图!

网站地图插件Google XML Sitemaps详细使用设置图文教程

默认选择是“评论数量”,你需要改成第一个(不使用自动优先级计算),所有文章都将拥有“优先级”设定中设置的那样的优先权,如下图。

网站地图插件Google XML Sitemaps详细使用设置图文教程

sitemap 站点地图内容按照这下边的勾选就可以了!

网站地图插件Google XML Sitemaps详细使用设置图文教程

更新时间这个就要根据你自己网站内容的更新频率来选择,一定要合理选择更新的时间,百度的蜘蛛会根据这个时间表来访问你的网站;

网站地图插件Google XML Sitemaps详细使用设置图文教程

网站的优先级就设置默认就可以了,当然你也可以根据自己的实际情况来调整。

网站地图插件Google XML Sitemaps详细使用设置图文教程

插件会自动生成 Sitemap 地址,一般路径为:https://你的域名/sitemap.xml,例如:

https://www.11zhang.com/sitemap.xml
网站地图插件Google XML Sitemaps详细使用设置图文教程

插件会自动向 Google 和 Bing 通知,但你也可以手动提交。

另外,如果你不喜欢 XML Sitemap Generator for Google 插件原本左对齐的 XML Sitemap 页面风格,也可以通过修改 /wp-content/plugins/google-sitemap-generator/sitemap.xsl 文件重构 HTML 结构美化,如下图。

图片[9]-网站地图插件 XML Sitemap Generator for Google 使用指南-十一张
图片[10]-网站地图插件 XML Sitemap Generator for Google 使用指南-十一张
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:html="http://www.w3.org/TR/REC-html40"
    xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <title>XML站点地图索引 - 十一张</title>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                <style type="text/css">
                    body {
                        margin: 0;
                        padding: 0;
                        min-height: 100vh;
                        display: flex;
                        justify-content: center;
                        background: #fff;
                        font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
                        font-size: 14px;
                        color: #333;
                    }

                    #wrapper {
                        width: 100%;
                        max-width: 960px;
                        padding: 30px 20px;
                    }

                    h1 {
                        font-size: 24px;
                        font-weight: normal;
                        margin: 0 0 15px 0;
                        padding-bottom: 10px;
                        border-bottom: 1px solid #e5e5e5;
                    }

                    #intro {
                        background: #f7fbff;
                        border: 1px solid #c5e1f6;
                        padding: 12px 15px;
                        margin-bottom: 20px;
                        line-height: 1.6;
                        color: #444;
                    }

                    table {
                        width: 100%;
                        border-collapse: collapse;
                        word-break: break-word;
                    }

                    th {
                        text-align: left;
                        padding: 10px;
                        border-bottom: 2px solid #ddd;
                        font-weight: 600;
                        color: #222;
                    }

                    td {
                        padding: 10px;
                        border-bottom: 1px solid #eee;
                    }

                    tr.high {
                        background-color: #fafafa;
                    }

                    a {
                        color: #1a73e8;
                        text-decoration: none;
                    }

                    a:hover {
                        text-decoration: underline;
                    }

                    #footer {
                        margin-top: 25px;
                        text-align: center;
                        font-size: 12px;
                        color: #999;
                    }
                </style>
            </head>

            <body>
                <div id="wrapper">
                    <xsl:apply-templates/>
                    <div id="footer">
                        <p><a href="https://www.11zhang.com" target="_blank">十一张</a> | 由 XML Sitemap Generator for Google 插件生成</p>
                    </div>
                </div>
            </body>
        </html>
    </xsl:template>

    <!-- URL 站点地图 -->
    <xsl:template match="sitemap:urlset">
        <h1>XML 站点地图</h1>

        <div id="intro">
            这是一个 XML 站点地图索引文件,用于指向多个子站点地图,符合百度、Google、Bing 等搜索引擎 Sitemap 协议。
        </div>

        <table>
            <tr>
                <th>URL</th>
                <th>优先级</th>
                <th>更新频率</th>
                <th>最后修改时间</th>
            </tr>

            <xsl:for-each select="sitemap:url">
                <tr>
                    <xsl:if test="position() mod 2 = 0">
                        <xsl:attribute name="class">high</xsl:attribute>
                    </xsl:if>

                    <td>
                        <a href="{sitemap:loc}">
                            <xsl:value-of select="sitemap:loc"/>
                        </a>
                    </td>

                    <td>
                        <xsl:value-of select="concat(format-number(sitemap:priority * 100, '0'), '%')"/>
                    </td>

                    <td>
                        <xsl:value-of select="sitemap:changefreq"/>
                    </td>

                    <td>
                        <xsl:value-of select="sitemap:lastmod"/>
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>

    <!-- Sitemap Index -->
    <xsl:template match="sitemap:sitemapindex">
        <h1>XML 站点地图索引</h1>

        <div id="intro">
            这是一个 XML 站点地图索引文件,用于指向多个子站点地图,符合百度、Google、Bing 等搜索引擎 Sitemap 协议。
        </div>

        <table>
            <tr>
                <th>子站点地图地址</th>
                <th>最后修改时间</th>
            </tr>

            <xsl:for-each select="sitemap:sitemap">
                <tr>
                    <xsl:if test="position() mod 2 = 0">
                        <xsl:attribute name="class">high</xsl:attribute>
                    </xsl:if>

                    <td>
                        <a href="{sitemap:loc}">
                            <xsl:value-of select="sitemap:loc"/>
                        </a>
                    </td>

                    <td>
                        <xsl:value-of select="sitemap:lastmod"/>
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>

</xsl:stylesheet>
© 版权声明
THE END
如果觉得这篇文章对您有帮助,可以收藏本网址,方便下次访问!
点赞3 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容