robots.txt
robots.txt文件是搜索引擎访问网站第一个要查看的文件。通过robots.txt文件搜索引擎可以确定哪些链接是搜索引擎可以访问的。哪些链接是不希望搜索引擎访问的。甚至可以告知允许哪些搜索引擎访问网站。相当于网站与搜索引擎之间的协议。在搜索引擎找到robots.txt文件后会以robots.txt来确定访问的范围。如果没有robots.txt文件。搜索引擎默认全部页面都是可以访问的。下面是我自己网站的robots.txt文件User-agent: *
Disallow:/api/
Disallow:/hapi/
Crawl-delay: 5
Sitemap: https://www.example.com/sitemap.xml
sitemap
sitemap文件就告诉搜索引擎网站有哪些链接以及链接的更新频率,sitemap可以为txt、html和xml格式
sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>sitemap.txt
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
>
<url>
<loc>http://www.example.com/test1/</loc>
<priority>0.3</priority>
<lastmod>2021-10-07</lastmod>
<changefreq>weekly</changefreq>
</url>
</urlset>
http://www.example.com/test1/sitemap.html
http://www.example.com/test2/
<!DOCTYPE html>
<head>
<title>网站地图</title>
<meta http-equiv="Content-type" content="text/html;" charset="UTF-8" />
<style>
body{font-family: Arial, "微软雅黑";font-size: 13px;}
ul, li{margin:0px; padding:0px; list-style:none;}ul{width:800px;margin-left: auto;margin-right: auto;}.title{width:800px;font-size: 18px;}.lks{float: left;padding-right: 15px;line-height: 30px;font-size: 16px;}
</style>
</head><body align="center">
<ul><li class="title"><h3>www.example.com网站地图:(2021-10-07)</h3></li>
<li class="lks">1、<a href="http://www.example.com/test1/" title="Example Domain" target="_blank">测试栏目</a></li>
</ul></body></html>
网友回复