From 1ae5e8c24e286b9e05d31b97a1830d69ddde8aa6 Mon Sep 17 00:00:00 2001 From: Arnaud Amant Date: Tue, 9 Sep 2025 14:24:18 +0200 Subject: [PATCH 1/2] SEO: Add a canonical link in all CMS pages --- app/code/core/Mage/Cms/Block/Page.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/core/Mage/Cms/Block/Page.php index b24786f226e..d5ab30ad6ac 100644 --- a/app/code/core/Mage/Cms/Block/Page.php +++ b/app/code/core/Mage/Cms/Block/Page.php @@ -93,6 +93,7 @@ protected function _prepareLayout() $head->setTitle($page->getTitle()); $head->setKeywords($page->getMetaKeywords()); $head->setDescription($page->getMetaDescription()); + $head->addLinkRel('canonical', Mage::getUrl(null, ['_direct' => $page->getIdentifier()])); } return parent::_prepareLayout(); From ce2b2fcaefc1b647ea89d65f81bd9d672a2f0204 Mon Sep 17 00:00:00 2001 From: Arnaud Amant Date: Wed, 10 Sep 2025 11:05:40 +0200 Subject: [PATCH 2/2] SEO: Add a canonical link in CMS homepage --- app/code/core/Mage/Cms/Block/Page.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/core/Mage/Cms/Block/Page.php index d5ab30ad6ac..6c6909d4622 100644 --- a/app/code/core/Mage/Cms/Block/Page.php +++ b/app/code/core/Mage/Cms/Block/Page.php @@ -93,7 +93,12 @@ protected function _prepareLayout() $head->setTitle($page->getTitle()); $head->setKeywords($page->getMetaKeywords()); $head->setDescription($page->getMetaDescription()); - $head->addLinkRel('canonical', Mage::getUrl(null, ['_direct' => $page->getIdentifier()])); + + if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'cms_index_index') { + $head->addLinkRel('canonical', Mage::getUrl()); + } else { + $head->addLinkRel('canonical', Mage::getUrl(null, ['_direct' => $page->getIdentifier()])); + } } return parent::_prepareLayout();