diff --git a/commcare_connect/prelogin/route_meta.py b/commcare_connect/prelogin/route_meta.py new file mode 100644 index 0000000000..ecfe4ddf56 --- /dev/null +++ b/commcare_connect/prelogin/route_meta.py @@ -0,0 +1,185 @@ +"""Per-route title, description, and social image for the marketing SPA. + +Every marketing URL renders the SAME home.html, so without this the whole site +would ship one : a reader sharing a blog post got the home page's title, +description, and image. app.js fixed that in the browser, but link unfurlers +(LinkedIn, Slack, X, iMessage) and non-rendering crawlers never run JavaScript, +so they only ever saw the home page. + +This module is the single source of truth. views.HomeView reads it to render the +head server-side, and home.html serializes it into a - + diff --git a/commcare_connect/templates/prelogin/home.html b/commcare_connect/templates/prelogin/home.html index c9729a3e9f..0cf08192fd 100644 --- a/commcare_connect/templates/prelogin/home.html +++ b/commcare_connect/templates/prelogin/home.html @@ -7,20 +7,25 @@ {% include "prelogin/includes/hubspot_embed.html" %} -Connect by Dimagi - - - +{# Per-route, from prelogin/route_meta.py. Every URL renders this one template #} +{# and unfurlers never run app.js, so hardcoding these makes every shared page #} +{# preview as the home page. #} +{{ page_meta.title }} + + + - - - - - + + + + + - - - + + + +{# The same table for app.js, so client and server cannot drift. #} +{{ route_meta|json_script:"route-meta" }} + diff --git a/pyproject.toml b/pyproject.toml index fe668a5190..88583e44e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,11 @@ extend-exclude = ["**/migrations/*.py"] # E/W: pycodestyle, F: pyflakes (flake8 defaults), I: isort select = ["E", "F", "W", "I"] +[tool.ruff.lint.per-file-ignores] +# Marketing page titles and meta descriptions: prose that has to stay on one +# line to be readable and greppable against the rendered . +"commcare_connect/prelogin/route_meta.py" = ["E501"] + [tool.ruff.lint.isort] known-first-party = ["commcare_connect", "config"]