2026 robots.txt 与 sitemap.xml SEO 设置指南
从速度、质量、隐私和移动端体验四个维度比较免费图片压缩服务,重点覆盖批量速度、清晰度、隐私策略和移动端体验差异,用于发布前的选型依据。内容适用于博客、详情页和社媒素材的实际发布流程。
要点摘要
2026年的SEO基础是用robots.txt说明抓取规则,用sitemap.xml提交规范URL。两者不能互相冲突。
2026 robots.txt 与 sitemap.xml SEO 设置指南
robots.txt syntax: User-agent, Disallow, Allow, Sitemap
Use robots.txt at the root of the host, for example https://millionscode.com/robots.txt. The practical 2026 baseline is simple: open the parts that should be crawled, block low-value operational paths, and declare the sitemap with a full URL. A safe starting point is:
User-agent: *
Allow: /
Sitemap: https://millionscode.com/sitemap.xmlFor a production site, treat Disallow carefully. A single Disallow: / can stop crawling of the whole host. That is useful on staging and dangerous on a live site. If admin pages, carts, search results, or temporary filters should not be crawled, block those paths only:
User-agent: *
Disallow: /admin/
Disallow: /search
Disallow: /cart
Allow: /blog/
Allow: /tools/
Sitemap: https://millionscode.com/sitemap.xmlrobots.txt is not a security layer. It is a crawler instruction file. Sensitive data must be protected by authentication, and pages that must disappear from search need the right removal method rather than only a crawl block.
sitemap.xml structure
A sitemap lists canonical URLs that deserve discovery. Keep it clean:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://millionscode.com/tools/meta-checker</loc>
<lastmod>2026-06-03</lastmod>
</url>
<url>
<loc>https://millionscode.com/blog/post-mp90fbw1</loc>
<lastmod>2026-06-03</lastmod>
</url>
</urlset>Do not mix canonical and non-canonical versions. Do not submit URLs blocked by robots.txt. Use /tools/meta-checker for metadata checks, /blog/post-mp90fbw1 for sitemap generation planning, /blog/api-mpj0hwex for indexing API workflow, and /blog/post-mpkfy95s for Search Console checks.
Submission: Search Console and Naver
In Google Search Console, verify the property and submit sitemap.xml or sitemap_index.xml in the Sitemaps report. Then check status, discovered URL count, fetch errors, and whether blocked URLs are accidentally present. In Naver Search Advisor, verify ownership, run robots.txt diagnosis, submit the sitemap, and watch collection requests separately. For Korean search traffic, Naver diagnostics should not be skipped.
Common mistakes
The first mistake is leaving a staging rule on production. The second is listing blocked URLs in the sitemap. The third is mixing www, non-www, http, and https versions. The fourth is changing lastmod every day without real content changes. The fifth is using robots.txt as an index removal tool. The reliable 2026 pattern is open crawl paths, submit only canonical URLs, and use console tools for diagnosis.
实务提示
For small and mid-size websites, the most useful habit is consistency. The pages in sitemap.xml should also be reachable through internal links. New posts, key tools, category pages, and evergreen guides should reinforce one another instead of living as isolated URLs. 每次发布路由、canonical、语言路径或自动XML生成逻辑后,都应重新检查这两个文件。
FAQ
robots.txt 会直接阻止索引吗?
不会。它主要控制抓取。删除或隐藏页面还需要 noindex、认证、删除工具或正确状态码。
Sitemap 行放在哪里?
使用完整 URL,通常放在 robots.txt 末尾。
Allow 一定优先吗?
通常更具体的路径优先,发布前要测试。
要放入所有 URL 吗?
只放规范且可索引的重要 URL。
提交后会马上收录吗?
不会,只是帮助发现和诊断。
Naver 也要提交吗?
面向韩国流量时建议提交并诊断。
🔧 相关免费工具
下一步
从本指南继续
相关
一份实用指南,介绍如何设计游戏流程,让来自搜索的用户在 1 分钟内获得成就感,并愿意在 3 到 8 分钟内再次回访,同时包含基于数据的检查点。...
SEO·开发Cloudflare Workers AI 2026 最新模型综述 - Llama 4 与 DeepSeek-V3 Edge 的成本/速度对比本指南基于 2026 年 Cloudflare Workers AI 的真实生产使用情况,对 Llama 4 和 DeepSeek-V3 Edge 在成本、速度...
SEO·开发使用 Playwright MCP Server 构建可靠 AI Agent 浏览器自动化的实用指南一份实用草稿,将 Playwright MCP 与 AI agents 连接起来,并把身份验证、错误处理、成本控制和故障恢复组织成可用于生产环境的模式。其策略驱...
SEO·开发Playwright vs Cypress 2026: 速度、DX、CI并行性 深入比较从速度、质量、隐私和移动端体验四个维度比较免费图片压缩服务,重点覆盖批量速度、清晰度、隐私策略和移动端体验差异,用于发布前的选型依据。内容适用于博客、详情页和社...