我想在我的Meteor应用(在*.meteor.com上)的staging部署中包含一个public/robots.txt文件,基本上是为了完全避免这个版本的站点被爬取。我该如何做到这一点?我正在使用meteor deploy
命令进行部署。
我想出了一个(希望是暂时的?)解决方案,使用一个部署脚本,在调用meteor deploy
之前创建public/robots.txt,并在最后删除public/robots.txt。
#!/usr/bin/env python
import subprocess
import os.path
dpath = os.path.dirname(__file__)
if dpath:
os.chdir(dpath)
if not os.path.exists('public'):
os.makedirs('public')
robots = None
try:
with open('public/robots.txt', 'wb') as robots:
robots.write("""User-agent: *
Disallow: /
""")
subprocess.check_call(["meteor", "deploy", '<myapp>.meteor.com'])
finally:
if robots is not None:
os.remove(robots.name)
meteor remove spiderable
,然后meteor deploy
,接着再使用meteor add spiderable
命令重新安装?或者只需在.meteor/packages
文件中注释掉相关行即可。 - sbking