🔍 robots and other optimizations
This commit is contained in:
17
app.py
17
app.py
@@ -239,6 +239,23 @@ def sitemap():
|
|||||||
return send_from_directory('static', 'sitemap.xml', mimetype='application/xml')
|
return send_from_directory('static', 'sitemap.xml', mimetype='application/xml')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/robots.txt')
|
||||||
|
def robots():
|
||||||
|
"""Generate robots.txt dynamically with correct SITE_URL"""
|
||||||
|
from flask import Response
|
||||||
|
robots_txt = f"""# Sunday Comics - Robots.txt
|
||||||
|
User-agent: *
|
||||||
|
Allow: /
|
||||||
|
|
||||||
|
# Sitemap location
|
||||||
|
Sitemap: {SITE_URL}/sitemap.xml
|
||||||
|
|
||||||
|
# Disallow API endpoints from indexing
|
||||||
|
Disallow: /api/
|
||||||
|
"""
|
||||||
|
return Response(robots_txt, mimetype='text/plain')
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def page_not_found(e):
|
def page_not_found(e):
|
||||||
"""404 error handler"""
|
"""404 error handler"""
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
<a href="{{ url_for('comic', comic_id=comic.number) }}">
|
<a href="{{ url_for('comic', comic_id=comic.number) }}">
|
||||||
<img src="{{ url_for('static', filename='images/thumbs/' + comic.filename) }}"
|
<img src="{{ url_for('static', filename='images/thumbs/' + comic.filename) }}"
|
||||||
onerror="this.onerror=null; this.src='{{ url_for('static', filename='images/thumbs/default.jpg') }}';"
|
onerror="this.onerror=null; this.src='{{ url_for('static', filename='images/thumbs/default.jpg') }}';"
|
||||||
alt="{{ comic.title if comic.title else '#' ~ comic.number }}">
|
alt="{{ comic.title if comic.title else '#' ~ comic.number }}"
|
||||||
|
loading="lazy">
|
||||||
<div class="archive-info">
|
<div class="archive-info">
|
||||||
{% if not archive_full_width %}
|
{% if not archive_full_width %}
|
||||||
<h3>#{{ comic.number }}{% if comic.title %}: {{ comic.title }}{% endif %}</h3>
|
<h3>#{{ comic.number }}{% if comic.title %}: {{ comic.title }}{% endif %}</h3>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
<!-- SEO Meta Tags -->
|
<!-- SEO Meta Tags -->
|
||||||
<meta name="description" content="{% block meta_description %}A webcomic about life, the universe, and everything{% endblock %}">
|
<meta name="description" content="{% block meta_description %}A webcomic about life, the universe, and everything{% endblock %}">
|
||||||
|
<link rel="canonical" href="{% block canonical %}{{ site_url }}{{ request.path }}{% endblock %}">
|
||||||
|
|
||||||
<!-- Open Graph / Facebook -->
|
<!-- Open Graph / Facebook -->
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
|
|||||||
@@ -4,6 +4,27 @@
|
|||||||
|
|
||||||
{% block og_image %}{{ site_url }}/static/images/thumbs/{{ comic.filename }}{% endblock %}
|
{% block og_image %}{{ site_url }}/static/images/thumbs/{{ comic.filename }}{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_css %}
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "ComicStory",
|
||||||
|
"name": "{{ comic.title if comic.title else '#' ~ comic.number }}",
|
||||||
|
"datePublished": "{{ comic.date }}",
|
||||||
|
"image": "{{ site_url }}/static/images/comics/{{ comic.filename }}",
|
||||||
|
"thumbnailUrl": "{{ site_url }}/static/images/thumbs/{{ comic.filename }}",
|
||||||
|
"description": "{{ comic.alt_text }}",
|
||||||
|
"isPartOf": {
|
||||||
|
"@type": "ComicSeries",
|
||||||
|
"name": "{{ comic_name }}",
|
||||||
|
"url": "{{ site_url }}"
|
||||||
|
},
|
||||||
|
"position": "{{ comic.number }}",
|
||||||
|
"url": "{{ site_url }}/comic/{{ comic.number }}"
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<!-- ARIA live region for screen reader announcements -->
|
<!-- ARIA live region for screen reader announcements -->
|
||||||
<div aria-live="polite" aria-atomic="true" class="sr-only" id="comic-announcer"></div>
|
<div aria-live="polite" aria-atomic="true" class="sr-only" id="comic-announcer"></div>
|
||||||
@@ -29,7 +50,8 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<img src="{{ url_for('static', filename='images/comics/' + comic.filename) }}"
|
<img src="{{ url_for('static', filename='images/comics/' + comic.filename) }}"
|
||||||
alt="{{ comic.title if comic.title else '#' ~ comic.number }}"
|
alt="{{ comic.title if comic.title else '#' ~ comic.number }}"
|
||||||
title="{{ comic.alt_text }}">
|
title="{{ comic.alt_text }}"
|
||||||
|
loading="eager">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -43,7 +65,8 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<img src="{{ url_for('static', filename='images/comics/' + comic.filename) }}"
|
<img src="{{ url_for('static', filename='images/comics/' + comic.filename) }}"
|
||||||
alt="{{ comic.title if comic.title else '#' ~ comic.number }}"
|
alt="{{ comic.title if comic.title else '#' ~ comic.number }}"
|
||||||
title="{{ comic.alt_text }}">
|
title="{{ comic.alt_text }}"
|
||||||
|
loading="eager">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user