The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Intermediate & Advanced SEO
    4. How to add Canonical Tags on Opencart Products

    How to add Canonical Tags on Opencart Products

    Intermediate & Advanced SEO
    6 3 1.2k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • moon-boots
      moon-boots last edited by

      Does anyone know how to add canonical tags to product pages in Opencart?

      Is this possible to do in htaccess? If so, how specifically should it be written in?

      Please do not post any links to other pages which reference generic canonical information as I've read them all and none help. I'm looking for an Opencart specific answer, or a way to do it in htaccess.

      1 Reply Last reply Reply Quote 0
      • Vijay-Gaur
        Vijay-Gaur last edited by

        Hi there,

        In continuation to my response earlier on another question.

        Have u tried these extensions on Opencart? http://www.opencart.com/index.php?route=extension/extension&filter_search=canonical url

        Thanks,

        Vijay

        1 Reply Last reply Reply Quote 0
        • Mustansar
          Mustansar last edited by

          I suggerst you to adopt the following :

          The best way to achieve this is to modify your Document class, set your canonical in your controller, then render it in the header controller.

          Edit system/library/document.php

          add:

          private $canonical; to your class variables up top.

          Then add the following methods:

          <code>publicfunction setCanonical($url){ $this->canonical = $url;}publicfunction getCanonical(){return $this->canonical;}</code>
          

          In your header controller add:

          $this->data['canonical'] = $this->document->getCanonical();

          Then you can set your canonical dynamically in the header controller:

          <code>if(isset($this->request->get['_route_'])): $canonical_route = $this->request->get['_route_'];else: $canonical_route =''; endif; $this->document->setCanonical($this->data['base']. $canonical_route);</code>
          

          Or you can set it manually in your controllers using the setCanonical method.

          moon-boots 2 Replies Last reply Reply Quote 2
          • moon-boots
            moon-boots @Mustansar last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • moon-boots
              moon-boots last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • moon-boots
                moon-boots @Mustansar last edited by

                Apparently this didn't work. According to the Moz tool I have the same amount of duplicate title tags as before.

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • Original Source Tag or Canonical Tag for News Publishers?
                  Carson-Ward
                  Carson-Ward
                  0
                  2
                  535

                • Putting rel=canonical tags on blogpost pointing to product pages
                  Tylerj
                  Tylerj
                  0
                  3
                  71

                • How to deal with canonicals on dup product pages in Opencart?
                  danwebman
                  danwebman
                  0
                  2
                  54

                • Use Nonindex or Canonical on product tags of a e-commerce site
                  PatrickDelehanty
                  PatrickDelehanty
                  1
                  15
                  766

                • Cross Domain Rel Canonical tags vs. Rel Canonical Tags for internal webpages
                  VanguardCommunications
                  VanguardCommunications
                  0
                  5
                  1.2k

                • Working to Start an Shopping Idea Site - Which Totally Based On Scraping product from Ecom. How Quickly I should Add products and categories in this new domain.
                  innovatebizz
                  innovatebizz
                  0
                  9
                  136

                • Is it ok to add rel=CANONICAL into the desktop version on top of the rel="alternate" Tag (Mobile vs Desktop version)
                  Ideas-Money-Art
                  Ideas-Money-Art
                  0
                  3
                  172

                • Canonical Tags?
                  Dr-Pete
                  Dr-Pete
                  0
                  9
                  540

                Get started with Moz Pro!

                Unlock the power of advanced SEO tools and data-driven insights.

                Start my free trial
                Products
                • Moz Pro
                • Moz Local
                • Moz API
                • Moz Data
                • STAT
                • Product Updates
                Moz Solutions
                • SMB Solutions
                • Agency Solutions
                • Enterprise Solutions
                • Digital Marketers
                Free SEO Tools
                • Domain Authority Checker
                • Link Explorer
                • Keyword Explorer
                • Competitive Research
                • Brand Authority Checker
                • Local Citation Checker
                • MozBar Extension
                • MozCast
                Resources
                • Blog
                • SEO Learning Center
                • Help Hub
                • Beginner's Guide to SEO
                • How-to Guides
                • Moz Academy
                • API Docs
                About Moz
                • About
                • Team
                • Careers
                • Contact
                Why Moz
                • Case Studies
                • Testimonials
                Get Involved
                • Become an Affiliate
                • MozCon
                • Webinars
                • Practical Marketer Series
                • MozPod
                Connect with us

                Contact the Help team

                Join our newsletter
                Moz logo
                © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                • Accessibility
                • Terms of Use
                • Privacy