add page robots.txt

master
A.C.Sukazyo Eyre 2023-01-26 17:12:57 +08:00
parent 00ae5cf3c8
commit 9965e18ad9
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
2 changed files with 51 additions and 0 deletions

View File

@ -9,4 +9,7 @@
</Chapter>
<Page id="custom" name="自定义网页样式" />
<Page id="plans" name="开发计划" />
<Chapter name="高级选项">
<Page id="enhanced/robots-policy" name="robots.txt" />
</Chapter>
</Book>

48
enhanced/robots-policy.md Normal file
View File

@ -0,0 +1,48 @@
# robots.txt - 搜索引擎爬虫规则
[robots.txt]: https://en.wikipedia.org/wiki/Robots.txt
ph-Bookshelf 提供了 `site.robots` 配置节点,可以允许站点管理员配置网站 [`/robots.txt`][robots.txt] 内容从而控制哪些网页可以被爬虫访问。
这个值只支持在站点配置(`bookshelf.xml`)中设置。因此,你无法在某个页面或是某个书籍的配置区域单独设置它们的访问控制。
默认取值为 `allow`
支持设置值为 `allow` | `deny` | `custom` | `file`,或其它任何值。
{ #allow }
## allow
当设置为 **`allow`** 时,将设置 robots.txt 为以下内容,这将允许任何爬虫访问网站的任何页面。
> 如果站点没有设置 `site.robots` 的值,那么这也是默认输出
```robots-txt
User-agent: *
Allow: /
```
{ #deny }
## deny
当设置为 **`deny`** 时,将设置 robots.txt 为以下内容,这将允许任何爬虫访问网站的任何页面。
```robots-txt
User-agent: *
Allow: /
```
{ #file }
## custom / file
当设置为 **`custom`** 或是 **`file`** 时ph-Bookshelf 将会使用站点数据根目录中的 `robots.txt` 文件作为站点 robots.txt。
> 如果你的数据目录中没有这个文件,那么将会不产生任何内容。
> <small>除非你的 PHP 的配置文件中 `display_error=On`:页面将输出 PHP 错误。</small>
{ #others }
## 其它任何值
当填入的值不为以上任何值时,**ph-Bookshelf** 将会把填入的值作为 robots.txt 的内容输出。
因此,你可以使用 `<![CDATA[]]>` 直接在这里填入你想要设置的 robots.txt 内容。<small>虽然我们仍然推荐使用 [`file`](#file) 方式而非这样的方式。</small>