News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Search engine friendly URLs setting

Started by MobileCS, February 14, 2024, 11:53:16 AM

Previous topic - Next topic

MobileCS

SMF 2.1.4

Regardless if this setting is enabled or not, the forum is hard coded to use non-friendly URL's as the "canonical URL" for topics and boards.

This of course creates all sorts of issues with Google and what forum URL gets indexed.

Sources\Display.php
// Set a canonical URL for this page.
$context['canonical_url'] = $scripturl . '?topic=' . $topic . '.' . ($can_show_all ? '0;all' : $context['start']);

Sources\MessageIndex.php
// Set a canonical URL for this page.
// $context['canonical_url'] = $scripturl . '?board=' . $board . '.' . $context['start'];

My temporary fix were to change those lines to :

$context['canonical_url'] = $scripturl . '/topic,' . $topic . '.' . ($can_show_all ? '0/all.html' : $context['start'] . '.html');
$context['canonical_url'] = $scripturl . '/board,' . $board . '.' . $context['start'] . '.html';



Arantor

The *entire software* is coded that way.

The search engine friendly setting should be rewriting every link it can find on the site that's internal and in the correct format.

The code that does the work is given the HTML of the entire page to rewrite.

MobileCS

It wasn't doing that here. I have over 2,000 entries in Google Search Console with "Alternate page with proper canonical tag" errors.

When I inspect the URL in GSC:
https://www.example.com/forum/index.php/board,21.0.html

It shows this:
User-declared canonical : https://www.example.com/forum/index.php?board=21.0

This was confirmed by doing a "view source" on the page. After my updates, the issue were resolved.

Arantor

What mods do you have? I'm not yet convinced this is a core bug (seeing how I fixed a bug in this some time ago where the canonical was genuinely mashed by things)

Aleksi "Lex" Kilpinen

Quote from: MobileCS on February 14, 2024, 11:53:16 AMThis of course creates all sorts of issues with Google and what forum URL gets indexed.

I have a forum with way over 3 million posts, I haven't seen any issues. Things get indexed just fine, Google complains sometimes but I honestly haven't seen any actual issues. AFAIK, the "non-friendly" URL should always work, so what exactly is the issue?
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Arantor

The issue is that Google finds the declared canonical and it's not the one the rest of the system wants to use so you're in effect producing an invalid canonical.

I'm willing to believe there is *an* issue but I'm not yet willing to accept it as a core issue until it has been ruled out that there are no mods touching that code, precisely because this should break so many more instances than it has done in the last decade and a half.


Arantor

Can't reproduce on a regular unmodified 2.1.4 - regular topic and messageindex produce the expected canonical values.

Would prefer to see it on your actual site (please don't PM me) as a guest.

Advertisement: