{"id":745,"date":"2013-03-01T00:00:00","date_gmt":"2013-03-01T00:00:00","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2013\/03\/01\/how-do-i-configure-django-to-serve-my-robotstxt-files\/"},"modified":"2021-07-24T18:07:27","modified_gmt":"2021-07-24T18:07:27","slug":"how-do-i-configure-django-to-serve-my-robotstxt-files","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html","title":{"rendered":"How do I configure Django to serve my Robots.txt file ?"},"content":{"rendered":"

Within this article we will look at how to configure Django to serve your ‘robots.txt’ file.<\/p>\n

Though there are a number of methods available to achieve this, this example we will only look at the Django urls.py method. In that only the the urls.py file within your Django project will need to be changed.<\/p>\n

Example<\/strong><\/h4>\n

Below is an example of the urls.py file. The additional lines that are required are displayed via the plus symbol.<\/p>\n

Based on this urls.py configuration the robots.txt file would need to be placed directly within your templates directory.<\/p>\n

  from django.conf.urls.defaults import patterns, include, url
+ from django.views.generic.simple import direct_to_template

  urlpatterns = patterns('',
      url(r'^example_home\/$', 'example.views.home'),
+     url(r'^robots\\.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text\/plain'}),
  )<\/pre>\n","protected":false},"excerpt":{"rendered":"

Within this article we will look at how to configure Django to serve your ‘robots.txt’ file. Though there are a number of methods available to achieve this, this example we will only look at the Django urls.py method. In that only the the urls.py file within your Django project will need to be changed. Example … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"yoast_head":"\nHow do I configure Django to serve my Robots.txt file ? - Fir3net<\/title>\n<meta name=\"description\" content=\"Within this article we will look at how to configure Django to serve your 'robots.txt' file. Though there are a number of methods available to achieve\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How do I configure Django to serve my Robots.txt file ? - Fir3net\" \/>\n<meta property=\"og:description\" content=\"Within this article we will look at how to configure Django to serve your 'robots.txt' file. Though there are a number of methods available to achieve\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\" \/>\n<meta property=\"og:site_name\" content=\"Fir3net\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-01T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-24T18:07:27+00:00\" \/>\n<meta name=\"author\" content=\"Rick Donato\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rick Donato\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\"},\"author\":{\"name\":\"Rick Donato\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\"},\"headline\":\"How do I configure Django to serve my Robots.txt file ?\",\"datePublished\":\"2013-03-01T00:00:00+00:00\",\"dateModified\":\"2021-07-24T18:07:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\"},\"wordCount\":110,\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"articleSection\":[\"Django\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\",\"url\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\",\"name\":\"How do I configure Django to serve my Robots.txt file ? - Fir3net\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/#website\"},\"datePublished\":\"2013-03-01T00:00:00+00:00\",\"dateModified\":\"2021-07-24T18:07:27+00:00\",\"description\":\"Within this article we will look at how to configure Django to serve your 'robots.txt' file. Though there are a number of methods available to achieve\",\"breadcrumb\":{\"@id\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.fir3net.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming\",\"item\":\"https:\/\/www.fir3net.com\/programming\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Web Development\",\"item\":\"https:\/\/www.fir3net.com\/programming\/web-development\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Django\",\"item\":\"https:\/\/www.fir3net.com\/programming\/web-development\/django\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How do I configure Django to serve my Robots.txt file ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.fir3net.com\/#website\",\"url\":\"https:\/\/www.fir3net.com\/\",\"name\":\"Fir3net\",\"description\":\"Keeping you in the know\",\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.fir3net.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.fir3net.com\/#organization\",\"name\":\"Fir3net\",\"url\":\"https:\/\/www.fir3net.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"contentUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"width\":390,\"height\":88,\"caption\":\"Fir3net\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\",\"name\":\"Rick Donato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"caption\":\"Rick Donato\"},\"description\":\"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How do I configure Django to serve my Robots.txt file ? - Fir3net","description":"Within this article we will look at how to configure Django to serve your 'robots.txt' file. Though there are a number of methods available to achieve","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html","og_locale":"en_US","og_type":"article","og_title":"How do I configure Django to serve my Robots.txt file ? - Fir3net","og_description":"Within this article we will look at how to configure Django to serve your 'robots.txt' file. Though there are a number of methods available to achieve","og_url":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html","og_site_name":"Fir3net","article_published_time":"2013-03-01T00:00:00+00:00","article_modified_time":"2021-07-24T18:07:27+00:00","author":"Rick Donato","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rick Donato","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html#article","isPartOf":{"@id":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html"},"author":{"name":"Rick Donato","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037"},"headline":"How do I configure Django to serve my Robots.txt file ?","datePublished":"2013-03-01T00:00:00+00:00","dateModified":"2021-07-24T18:07:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html"},"wordCount":110,"publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"articleSection":["Django"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html","url":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html","name":"How do I configure Django to serve my Robots.txt file ? - Fir3net","isPartOf":{"@id":"https:\/\/www.fir3net.com\/#website"},"datePublished":"2013-03-01T00:00:00+00:00","dateModified":"2021-07-24T18:07:27+00:00","description":"Within this article we will look at how to configure Django to serve your 'robots.txt' file. Though there are a number of methods available to achieve","breadcrumb":{"@id":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.fir3net.com\/Web-Development\/Django\/how-do-i-configure-django-to-serve-my-robotstxt-files.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fir3net.com\/"},{"@type":"ListItem","position":2,"name":"Programming","item":"https:\/\/www.fir3net.com\/programming"},{"@type":"ListItem","position":3,"name":"Web Development","item":"https:\/\/www.fir3net.com\/programming\/web-development"},{"@type":"ListItem","position":4,"name":"Django","item":"https:\/\/www.fir3net.com\/programming\/web-development\/django"},{"@type":"ListItem","position":5,"name":"How do I configure Django to serve my Robots.txt file ?"}]},{"@type":"WebSite","@id":"https:\/\/www.fir3net.com\/#website","url":"https:\/\/www.fir3net.com\/","name":"Fir3net","description":"Keeping you in the know","publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fir3net.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.fir3net.com\/#organization","name":"Fir3net","url":"https:\/\/www.fir3net.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","contentUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","width":390,"height":88,"caption":"Fir3net"},"image":{"@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037","name":"Rick Donato","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","caption":"Rick Donato"},"description":"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders."}]}},"_links":{"self":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/745"}],"collection":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/comments?post=745"}],"version-history":[{"count":0,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/745\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/media?parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/categories?post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/tags?post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}