Skip to content

Commit

Permalink
Add an extensible template for robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
opsyne committed Jun 30, 2022
1 parent bac7290 commit 2f5127a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions content/robots.txt/contents.lr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_template: robots.txt
---
_discoverable: no
---
_model: none
19 changes: 19 additions & 0 deletions templates/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{%- macro capitalize_first(text) -%}
{{- text[0].upper() -}}{{- text[1:] -}}
{%- endmacro -%}
User-agent: *
Disallow: /javascript/*
Disallow: /scss/*
Disallow: /static/*

{#- the '\n' is because we need a newline,
but we need to strip trailing and leading whitespace as well.
fragile, be careful #}
{% for user_agent, directives in bag('robots_txt').items() -%}
{{ '\n' }}User-agent: {{ user_agent }}
{%- for directive, values in directives.items() -%}
{%- for value in values -%}
{{ '\n' }}{{ capitalize_first(directive) }}: {{ value -}}
{% endfor -%}
{% endfor %}
{% endfor %}

0 comments on commit 2f5127a

Please sign in to comment.