Skip to content

Commit 31bac81

Browse files
authored
Merge pull request #14800 from nextcloud/copilot/add-meta-robots-noindex
Prevent indexing of non-stable docs versions and publish stable-only crawl policy
2 parents b43bde2 + 4b73b25 commit 31bac81

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/sphinxbuild.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,23 @@ jobs:
498498
echo "has_changes=true" >> $GITHUB_OUTPUT
499499
fi
500500
501+
- name: Strip noindex from stable docs
502+
run: |
503+
# Strip noindex from stable docs – these are the canonical pages we want indexed
504+
if [ -d server/stable ]; then
505+
find server/stable -name '*.html' -print0 | \
506+
xargs -0 perl -pi -e 's{<meta name="robots" content="noindex, follow" />\n?}{}g'
507+
fi
508+
509+
- name: Write robots.txt
510+
run: |
511+
cat > robots.txt << 'EOF'
512+
User-agent: *
513+
# Only the stable version should be indexed
514+
Allow: /server/stable/
515+
Disallow: /server/
516+
EOF
517+
501518
# Remove the stage/ directory BEFORE creating the PR so it doesn't get committed
502519
- name: Clean up staging cache before commit
503520
run: rm -rf stage/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends "!layout.html" %}
2+
{% block extrahead %}
3+
{{ super() }}
4+
<meta name="robots" content="noindex, follow" />
5+
{% endblock %}

0 commit comments

Comments
 (0)