Skip to content

Commit d7231cc

Browse files
Copilotskjnldsv
authored andcommitted
feat(seo): add noindex handling and robots.txt deployment controls
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/94393687-97e6-46db-ae6e-523576c970ab Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
1 parent 1de3fd3 commit d7231cc

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/sphinxbuild.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ jobs:
387387
run: |
388388
find "stage/${{ needs.stage-and-check.outputs.branch_name }}" -name '*.html' -print0 | while IFS= read -r -d '' f; do
389389
perl -0pi -e 's{^\s*<link rel="canonical" href="https://docs\.nextcloud\.com/server/[^"]*" />\n}{}m' "$f"
390+
perl -pi -e 's{<meta name="robots" content="noindex, follow" />\n?}{}g' "$f"
390391
done
391392
ls -la stage/*
392393
@@ -504,6 +505,24 @@ jobs:
504505
echo "has_changes=true" >> $GITHUB_OUTPUT
505506
fi
506507
508+
- name: Strip noindex from stable docs
509+
run: |
510+
# Strip noindex from stable docs – these are the canonical pages we want indexed
511+
if [ -d server/stable ]; then
512+
find server/stable -name '*.html' -print0 | \
513+
xargs -0 perl -pi -e 's{<meta name="robots" content="noindex, follow" />\n?}{}g'
514+
fi
515+
516+
- name: Write robots.txt
517+
run: |
518+
cat > robots.txt << 'EOF'
519+
User-agent: *
520+
# Only the stable version should be indexed
521+
Allow: /server/stable/
522+
Disallow: /server/
523+
Sitemap: https://docs.nextcloud.com/sitemap.xml
524+
EOF
525+
507526
# Remove the stage/ directory BEFORE creating the PR so it doesn't get committed
508527
- name: Clean up staging cache before commit
509528
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)