【发布时间】:2026-01-03 08:25:01
【问题描述】:
我通过 web.dev 对我的网站进行了 Lighthouse 测试,在那里我看到了 2 个我无法理解的“错误”。
第一点:“表单元素没有关联的标签”。
Lighthouse 认为我不使用表单的标签。但是,我的代码中有以下内容:
<input id="burger" type="checkbox" />
<label for="burger">
这是我唯一一次使用input。
那么为什么会出现这条消息呢?
第二点:“robots.txt 无效”。
我将以下内容用于我的 robots.txt 文件:
User-agent: *
Disallow: /testlab/
Disallow: /en/page-not-found.htm
Disallow: /en/page-not-found.htm
User-agent: WebReaper
User-agent: WebCopier
User-agent: Offline Explorer
User-agent: HTTrack
User-agent: Microsoft.URL.Control
User-agent: EmailCollector
User-agent: penthesilea
Disallow: /
sitemap: https://link-to-sitemap.com
据我所知,内容应该被不同的爬虫识别。
那么为什么我认为这是 Lighthouse 测试中的错误?
这里是网站的链接,如果你想自己运行测试:https://type-error.netlify.app
一个小提示:我已经通过 netlify.toml 文件设置了重定向和标头,也许这会有所帮助。
编辑:使用 Chrome 开发工具运行 Lighthouse 测试时,显示 robots.txt 的更多信息:“Lighthouse 无法下载 robots.txt 文件”。
【问题讨论】:
-
您是否要共享指向该页面的链接,从您所显示的内容来看,一切似乎都很好,但显示错误的原因可能有很多。
-
@GrahamRitchie 是的,当然。这是网页的链接:type-error.netlify.app
标签: html seo robots.txt lighthouse