All case studies

Why Google was reading a redirect page

Planit’s articles looked right in a browser and right when shared on WhatsApp. Search engines were getting something else: a page with a title, a redirect script and no article.

Project
Planit Traveler, public pages
My part
Diagnosis, backend, Nginx rules and tests
Built with
Django, React, Nginx
Status
Fixed October 2026, extended in November

The symptom

Google Search Console showed the HTML that Google had stored for public pages. The body said “Redirecting to” and little else. Nothing was failing: every request returned 200, the site worked, and shared links had the right picture and title.

The cause

Planit is a React app, and link-preview bots don’t run JavaScript. To give them something to read, Django middleware recognizes their user agents and returns a small page of preview tags. This was its list:

BOT_USER_AGENTS = (
    'whatsapp',
    'facebookexternalhit',
    'twitterbot',
    ...
    'pinterest',
    'googlebot',
    'bingbot',
    'applebot',
    'ia_archiver',
)
The user agents that received the preview page, trimmed. Python, before the fix.

A preview bot reads the tags and leaves. A search engine keeps the page it was given. The template made it worse, and its own comment holds the wrong assumption:

<!-- Redirect real browsers to the React SPA
     (bots ignore this) -->
<script>
  window.location.replace("{{ url }}");
</script>
...
<p>Redirecting to
  <a href="{{ url }}">{{ title }}</a></p>
The preview template, trimmed. Before the fix.

Google does run JavaScript. It was being handed an empty page that told it to go somewhere else.

Constraints

  • Previews on WhatsApp, Facebook and others had to keep working.
  • The same list existed in both Django and Nginx, and the two had to change together.
  • Private and unpublished trips must never appear in a preview.

The fix

The fix was mostly a removal. Search engines came out of the list, and the redirect script came out of the template:

  BOT_USER_AGENTS = (
      'whatsapp',
      'facebookexternalhit',
      ...
-     'pinterest',
-     'googlebot',
-     'bingbot',
-     'applebot',
-     'ia_archiver',
+     'pinterestbot',
+     'pinterest/0.',
  )
The change to the list, trimmed. Lines starting with - were removed, + added. Python.

A comment above the list now says why search engines must stay off it, so the next person doesn’t add them back.

The Pinterest entry changed too. Matching the word “pinterest” also matched people reading inside the Pinterest app, who were being sent the preview page as well.

That let search engines reach the React app. In the following weeks I moved the public pages to server-rendered HTML, so an article’s text is there before any script runs.

How it was tested

The tests send each kind of visitor to each kind of public page. Search engines must reach the real one:

for user_agent in SEARCH_ENGINE_UAS:
    for path in self.paths:
        self.assertIs(
            self.run_middleware(
                path, user_agent),
            self.passthrough)
The routing test for search engines, trimmed. Python.
Run on 23 November 2026 against the main branch
SuiteCoversResult
Preview routing, backendSearch engines, browsers, preview bots, private and unpublished content16 of 16 passed
Sitemap, backendPublic pages only, canonical addresses10 of 10 passed
Article pages, backendServer-rendered text, metadata and links24 of 24 passed

The live site was also asked for one article three times, changing only the user agent:

Live check on 23 November 2026
Sent asReceivedSize
ChromeThe article116,091 bytes
GooglebotThe same article116,091 bytes
WhatsAppThe preview page2,467 bytes

Outcome and limits

Search engines and readers now receive the same page. I don’t claim a ranking or traffic gain. The indexing reports I have can’t separate this change from the work that followed it.

Next: My own photos wouldn’t upload