Discourse App Bug: Canonical Meta Data Does Not Change Correctly in Discourse App

There is a bug in the Discourse app related to updating the <link rel="canonical"> meta data element in the <head> section of the Discourse DOM.

Basically, when a browser client enters the application, and the application is first loaded, the <link rel="canonical" href=""> element will set according to that initial page load; but then when a user clicks in the app (normal user behavior), without reloading the page manually, the <link rel="canonical"> link will not update.

I have tested this bug and reproduced it on the meta site:

Fig 1. Enter meta from the home page, the canonical link is correct, as it the title element.

Fig 2. Visit a topic. The title element changes correctly, but the canonical link is not correct (does not update as it should).

Fig 3. Visit another topic. The title element changes correctly, but the canonical link is not correct (does not update as it should).

Implications for SEO

This bug could adversely effect SEO because when Google indexes the page, if Googlebot is not "hard reloading" every page, the canonical information will be incorrect for each page (as in the image sequences above).

Reproducibility

I have reproduced this bug consistently on both the meta site and our site.

Notes

I have seen these kind of node.js (SPA) lifecycle issues before with other web frameworks (not only Ember) where DOM elements are not updated, based on (Ember and other SPA framework) lifecycle hooks within the web application framework.

Bug Reported at Meta

Wow!! Good catch.

The meta team thinks it is not a problem because they do not serve the SPA to GoogleBot.

However, because they do not serve the SPA to GoogleBot, this causes other problems and helps explain why many Discourse users have problems getting their pages crawled.

For example, since Discourse does not serve the SPA to GoogleBot, all of the "Suggested Topics" at the bottom of each topic are not shown to GoogleBot as well.

You can test this by setting your UA to GoogleBot in the dev console:

As meta told me just now, the SPA is not served to GoogleBot, and so a lot of features like "Suggested Topics" are gone from the page, according to what is served to GoogleBot.

Need to think about this more carefully.

I have, in a heavy-handed way, removed all canonical (topic) tags from Discourse.

1 Like