このチュートリアルを使用して、Django WebサイトをElastic Beanstalkにデプロイしました。 https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/
しかし、favicon.ico、robots.txt、sitemap.xmlをどこにどのように配置すればよいかわかりません。何か案は?
回答:
回答№1は1サイトマップを機能させるには、 django.contrib.sitemaps
フレームワーク: ドキュメント。または、静的な量のページがある場合は、次のようにします。
urlpatterns = [
# your robots.txt (and/or humans.txt) file:
url(r"^robot.txt$", TemplateView.as_view(
template_name="txt/robots.txt",
content_type="text/plain"
)),
# your static sitemap:
url(r"^crossdomain.xml$", TemplateView.as_view(
template_name="txt/sitemap.xml",
content_type="application/xml"
)),
]
のために favicon.ico
あなたの中にそれを置きます static
フォルダーを作成し、テンプレートで次のテンプレートタグを使用します。
<link rel="icon" href="{% static "path/to/favicon.ico" %}" sizes="...">
すべてのデバイスをサポートすることを忘れないでください: ファビコンの全リスト
回答№2の場合は1
のために favicon.ico
そして sitemap.xml
あなたはそれらを置くことができます static/
ディレクトリで、静的URLを使用してテンプレートでそれらを参照します。例えば。:
<link rel="shortcut icon" type="image/png" href="{{STATIC_URL}}/favicon.ico"/>
きみの robots.txt
少し難しくなります(djangoアプリと同様)。にドロップできます templates
ディレクトリと urls.py
次のものがあります:
urlpatterns = patterns("",
...
(r"^robots.txt$", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
)