{% extends "base.html" %} {% block htmltitle %} {# Pages with a frontmatter title (home + conf/area index pages) use it verbatim, dropping Material's " - {site_name}" suffix that otherwise eats ~17 width units and truncates the SEO hook in Google SERPs. Paper pages have no frontmatter title and keep the default suffix via super(). #} {%- if page and page.meta and page.meta.title %} {{ page.meta.title }} {%- elif page and page.is_homepage %} {{ config.site_name }} {%- else %} {{ super() }} {%- endif %} {% endblock %} {% block extrahead %} {% if config.extra.bing_site_verification %} {% endif %} {# Cloudflare Web Analytics — cookieless, no consent banner needed. Load only on the canonical host so legacy GitHub Pages copies and previews cannot contaminate production analytics. #} {% if config.extra.cloudflare_analytics_token %} {% endif %} {% if page and page.url == 'search/' %} {% else %} {% endif %} {# hreflang: bilingual alternate URLs for zh / en sites. Only emitted for pages that exist on BOTH sites — the set is loaded by hooks/hreflang.py from .hreflang_pairs.json (generated by src/gen_hreflang_pairs.py in the parent Auto-Research repo). Avoids 404 hreflang clusters which Google penalises. #} {% set _alt_pages = config.extra.hreflang_pairs %} {% if _alt_pages and page and page.url in _alt_pages %} {% endif %} {% if page %} {# Detect page type — frontmatter title already carries any '[论文解读]' prefix from src/add_seo.py, so the template never adds another prefix. #} {% set _src = (page.file.src_uri if page and page.file else '') %} {% set _is_index = _src.endswith('index.md') %} {% set _is_paper = page and not page.is_homepage and not _is_index %} {# Prefer frontmatter `title:` (SEO-tuned) over nav entry / H1 (page.title). #} {# _seo_title_raw is the unescaped form for JSON-LD (uses | tojson). #} {# _seo_title is HTML-escaped for use in OG / Twitter meta attribute values. #} {% set _seo_title_raw = (page.meta.title if page and page.meta and page.meta.title else page.title) %} {% set _seo_title = _seo_title_raw | e %} {% set _desc_raw = (page.meta.description if page and page.meta and page.meta.description else (config.site_description | default(''))) %} {% set _desc = _desc_raw | e %} {% set _tags = (page.meta.tags if page and page.meta and page.meta.tags else []) %} {% if _tags %} {% if _is_paper %} {% for tag in _tags %} {% endfor %} {% endif %} {% endif %} {# All JSON-LD string values use | tojson (NOT | e) to avoid GSC "Bad escape sequence in string" errors. HTML-escape produces & / " etc. which pollute JSON output, and never escapes the literal \ that crashes the JSON parser when titles/descriptions contain LaTeX (\theta, \boldsymbol, ...) #} {% if page.is_homepage %} {% elif _is_index %} {% else %} {% endif %} {# Build crumbs: every ListItem MUST have an "item" URL (Google requirement). #} {# Derive ancestor URLs from canonical_url segments, dedupe against current page. #} {% if page and not page.is_homepage %} {% set _site = config.site_url.rstrip('/') %} {% set _canon = page.canonical_url.rstrip('/') ~ '/' %} {% set _rel = _canon[(_site|length + 1):].rstrip('/') %} {% set _segs = _rel.split('/') if _rel else [] %} {% set _ancestors = page.ancestors | reverse | list %} {% set ns = namespace(items=[{'name': 'AI Paper Notes', 'url': _site ~ '/'}]) %} {% for anc in _ancestors %} {% set _depth = loop.index %} {% if _depth <= _segs|length %} {% set _url = _site ~ '/' ~ (_segs[:_depth] | join('/')) ~ '/' %} {% if _url != _canon %} {% set ns.items = ns.items + [{'name': anc.title, 'url': _url}] %} {% endif %} {% endif %} {% endfor %} {% set ns.items = ns.items + [{'name': page.title, 'url': _canon}] %} {% endif %} {% endif %} {% endblock %} {% block site_nav %} {% if nav %} {% set hidden = "" %} {% if page.meta and page.meta.hide %} {% set hidden = "hidden" if "navigation" in page.meta.hide %} {% endif %} {% endif %} {% if "toc.integrate" not in features %} {% set hidden = "" %} {% if page.meta and page.meta.hide %} {% set hidden = "hidden" if "toc" in page.meta.hide %} {% endif %} {% endif %} {% endblock %} {# B3: MathJax library is loaded only on paper pages. The config (javascripts/mathjax.js) stays global via extra_javascript and is rendered by super() before this script, so window.MathJax is defined first; index / home pages skip the ~1 MB tex-mml-chtml download entirely. #} {% block scripts %} {{ super() }} {% set _src = (page.file.src_uri if page and page.file else '') %} {% if page and not page.is_homepage and not _src.endswith('index.md') %} {% endif %} {% endblock %} {% block content %} {% if page %} {% set _src = (page.file.src_uri if page.file else '') %} {% set _is_index = _src.endswith('index.md') %} {% set _is_paper = not page.is_homepage and not _is_index %} {% if _is_paper and page.meta and page.meta.description %} {% endif %} {% endif %} {{ super() }} {% endblock %}