Basic SEO optimization for OpenCart
Today we will talk about the website management system - OpenCart. With this system you can build online stores of any complexity and quickly launch sales. But like any other CMS, it has its drawbacks…
Today we will talk about the website management system - OpenCart. With this system you can build online stores of any complexity and quickly launch sales. But like any other CMS, it has its drawbacks that you should address as soon as possible to make your site work better. Let's discuss the shortcomings in terms of search engine optimization for OpenCart CMS versions 2.x.x.x and 3.x.x.x. It is too early to discuss the new 4.0.0.0 release because it is very raw, and the official repository shows that a new release with a lot of changes is being prepared.
Basic SEO optimization is of course present in OpenCart. It includes meta tags such as Title, Meta Description, Meta Keywords (the latter, by the way, have long not been used by Google), SEO-friendly URLs, gzip compression, XML and HTML sitemaps, and breadcrumbs. But besides this, there are issues with duplicate pages, no ability to set meta tags for some pages (for example, Contacts), no microdata, no Open Graph tags, no simplified versions of pages for mobile devices (so-called AMP pages), and canonical tags are not present on all pages. If you have a multilingual site, prepare for even more problems — for example, no ability to set different meta tags in different languages for the home page, no support for language prefixes in URLs, no hreflang tags for linking multilingual pages, no multilingual sitemap.
In many of these cases, specialized SEO modules for OpenCart can help solve the problems, but you can also do without them if you put in a bit of effort, since it is worth it. Let's figure out what needs to be done first to get your online store onto the first pages of search results.
Main stages of SEO optimization for an OpenCart site
- Enable and configure SEO-friendly URLs and fill in SEO URL fields
- Remove duplicates of the home page
- Close unnecessary pages from indexing
- Configure caching and gzip compression
- Verify the presence of an h1 heading on all indexable pages, add description texts and meta tags
- Optimize images, add dimensions, alt and title attributes
- Organize a correct site structure, heading hierarchy, and content. Set up internal linking between pages.
- Add microdata and Open Graph meta tags
- Get rid of errors in the JavaScript console
- Validate HTML and CSS code through the W3C validator
- Check site performance with PageSpeed Insights
- Work on link-building and SMM
1. Configuring SEO-friendly URLs in OpenCart
For SEO-friendly URLs in OpenCart to work correctly, it is recommended to install the free SEO PRO module — it allows you to remove duplicate pages, display the full path in breadcrumbs, and also adds a "Main category" entity to products. The module is very easy to install — simply upload it through the admin panel and refresh the modifications. After that, you need to enable SEO URLs in the store settings under System > Settings > Store > Server tab. You also need to rename the htaccess.txt file located in the site root to .htaccess
Now it is important to make sure the SEO URL field is filled in for all pages. This can be done manually by editing each page — category, product, etc. — or you can use modules for automatic SEO URL generation, so-called SEO URL generators. You can find both paid and free options for such extensions.
If after these actions your site's links have not become SEO-friendly URLs, you need to clear the system cache.
2. Removing home page duplicates in OpenCart
As good as SEO Pro is, it does not remove all home page duplicates, so you need to configure 301 redirects from all possible URL variants to a single canonical URL.
What variants of links to the home page may exist? For example:
http://site.com
https://site.com
http://site.com/
https://site.com/
http://www.site.com
https://www.site.com
http://www.site.com/
https://www.site.com/
http://site.com/index.html
http://site.com/index.php
etc.
To eliminate such duplicates, you need to add redirect rules to the .htaccess file we have already mentioned. Below are the rules for some cases:
# Redirect links from http to https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Redirect links from www to https links without www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
3. Closing unnecessary pages from indexing
Pages can be closed from indexing in several ways:
- via the robots.txt file located in the root directory of the site
- using the HTTP header X-Robots-Tag: noindex
- using the meta tag
By the way, functionality for managing the noindex tag through the admin panel is present in the ocStore distribution out of the box.
In order to prohibit indexing of pages via robots.txt, you need to add rules to this file, each on a new line:
Disallow: /page1
Disallow: /page2
If you need to prohibit indexing for a specific bot, add a line with the bot's name before the rules, for example:
User-agent: Baiduspider
Or if the following rules apply to all bots except the ones specified above:
User-agent: *
4. Configuring caching and compression
Gzip compression can be enabled in the store settings under System > Settings > Store > Server tab > Compression level, set a value from 0 to 9. We do not recommend setting too high a compression level to avoid problems with some AJAX scripts.
Server-side compression can also be enabled using rules in the .htaccess file — at the very end, add rules for compressing HTML, CSS, JS, JSON, XML, and fonts:
AddOutputFilterByType DEFLATE text/plain text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon
AddOutputFilterByType DEFLATE x-font-ttf application/x-font-opentype image/svg+xml
To make the server send caching headers for images, styles, scripts, and fonts to the browser, you need to add the following rules:
# Enable expires
ExpiresActive On
# Default a cache expiration
ExpiresDefault "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
# Fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
ExpiresActive on
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
By the way, the cache lifetime "1 year" here can be changed at your discretion, for example to "3 month" or "5 day".
5. Checking the presence of h1 headings, descriptions, and meta tags.
Texts are very important for SEO, but it is equally important to format them correctly. For example, the page heading should be inside an h1 tag, but in some templates headings are for some reason wrapped in h2 tags. This is wrong. You need to review all template files and make the headings h1 specifically. You also need to add descriptions and meta tags for all pages.
We recommend using the free service from Ahrefs https://app.ahrefs.com/site-audit for automatic analysis of site content and checking for possible content errors, such as the presence of h1 and meta tags.
Headings, descriptions, and meta tags must be unique — do not copy the same texts from page to page. Your site's positions in search results will depend on this.
6. Optimizing images and adding their descriptions
Images on the site must also be optimized. If your online store is still being populated or is not large, you can convert all images into the specially optimized .webp format. But if you have a live site with many products, you can optimize the existing images. The free Caesium application can help you with this. You need to download the folder with images from your server, run them through this program, and upload them back to the server.
It is also important to add unique descriptions for images using the alt and title attributes — they should contain keywords. In addition, it is worth specifying image dimensions using the width and height attributes — this is important for the modern PageSpeed metric Cumulative Layout Shift (CLS), which tracks layout shifts after the initial layout render during loading.
Read the continuation in the next article about site optimization...