Skip to content

Commit 566e15b

Browse files
committed
Merge branch 'i7-robots-txt' into 'main'
Add an extensible template for robots.txt Closes #7 See merge request tpo/web/lego!65
2 parents 9e7d362 + 2f5127a commit 566e15b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

content/robots.txt/contents.lr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
_template: robots.txt
2+
---
3+
_discoverable: no
4+
---
5+
_model: none

templates/robots.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{%- macro capitalize_first(text) -%}
2+
{{- text[0].upper() -}}{{- text[1:] -}}
3+
{%- endmacro -%}
4+
User-agent: *
5+
Disallow: /javascript/*
6+
Disallow: /scss/*
7+
Disallow: /static/*
8+
9+
{#- the '\n' is because we need a newline,
10+
but we need to strip trailing and leading whitespace as well.
11+
fragile, be careful #}
12+
{% for user_agent, directives in bag('robots_txt').items() -%}
13+
{{ '\n' }}User-agent: {{ user_agent }}
14+
{%- for directive, values in directives.items() -%}
15+
{%- for value in values -%}
16+
{{ '\n' }}{{ capitalize_first(directive) }}: {{ value -}}
17+
{% endfor -%}
18+
{% endfor %}
19+
{% endfor %}

0 commit comments

Comments
 (0)