Django动力cms
项目描述
我们内部的一个实用工具,便于在开发和生产中轻松地拥有robots.txt
安装
pip install djrobots
用法
将djrobots URL添加到您的URLconf中,您就完成了!
(r'^robots\.txt$', include('djrobots.urls')),
并将djrobots添加到您的INSTALLED_APPS中。
如果您想禁用网站上的所有功能,请在设置中使用
DJROBOTS_DISALLOWALL = True
网站地图
如果您想在robots.txt中指定网站地图URL,请提供设置中的视图名称
DJROBOTS_SITEMAPS = 'sitemap-root'
DJROBOTS_SITEMAPS是一个特殊设置,您可以使用数组在robots.txt中指定更多网站地图
DJROBOTS_SITEMAPS = ['sitemap-root', 'department-sitemap']
或者您可以混合使用视图名称和原始URL
DJROBOTS_SITEMAPS = ['sitemap-root', 'department-sitemap', '/my-sitemap-index.xml']
定制
默认情况下,djrobots为生产提供了robots.txt模板,为开发提供了robots-debug.txt模板,默认配置在Lotrek内部使用。
如果您想指定更多指令,可以扩展默认模板、robots.txt和robots-debug.txt
{% extends "djrobots/base-robots.txt" %}
{% block content %}
User-agent: *
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: {% url 'documents' %}
Host: example.com
{% endblock %}
运行测试
$ pip install -r requirements-dev.txt
$ make test
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
djrobots-0.0.8.tar.gz (4.1 kB 查看哈希值)
构建分发
djrobots-0.0.8-py2.py3-none-any.whl (5.9 kB 查看哈希值)
关闭
djrobots-0.0.8.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a1483bb82d9be261251ed481dc068ace2f0d8b75c50e31d905bed36e5a057efe |
|
MD5 | d781d864a1ade0f755a59a71e63da494 |
|
BLAKE2b-256 | c5a87dff03b97cbf619a00d5414806f17a89802170ec2f6ae1e59116ddffa10f |
关闭
djrobots-0.0.8-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e8e42eb8cdb96f985c1898b4290322d8215944e080e9cf9d975c0f66ee542b06 |
|
MD5 | 89e6c90d0a8f3d21bda36ec55048bdd2 |
|
BLAKE2b-256 | 9bc33e57672d0a504f81a319cacb0a34dc750e9cc137c387375638a70f61e119 |