Skip to content
Canonical Tagging Support for AEM SEO
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
seo
.travis.yml
LICENSE
README.md
pom.xml

README.md

Build Status Coverage Status License

Canonical Tagging Support for AEM

This is a library for inserting canonical tags into your pages.

Why this library has been created

Many sites require content duplication. For example, there can be a sub-tree for each department in the company, where they have their content. However, they may have content which is equal to content in the corporate section.

At the same time, content duplication can greatly affect your ranking. Unfortunately, AEM does not provide flexible way of handling this.

Features

This library provides next features:

  • strict mapping, e.g. /path/page1 --(has canonical page)--> /anotherPath/page1
  • mapping by the pattern with lookup path, e.g. /path/page[0-9] --(all pages under path have canonical pages)--> /anotherPath

Library has been tested on AEM 6.1 SP1, and JDK 7/8.

Usage

Maven

Add maven dependency to your project:

    <dependency>
        <groupId>com.taradevko</groupId>
        <artifactId>com.taradevko.aem.seo</artifactId>
        <version>0.1.1</version>
    </dependency>

Embed bundle into the content package to be installed. It may look like this:

    <embedded>
         <groupId>com.taradevko</groupId>
         <artifactId>com.taradevko.aem.seo</artifactId>
         <filter>true</filter>
    </embedded>

Building from the sources

To build and install bundle to your AEM instance, use next command (host/port values should be adjusted to the values you have):

mvn clean install -PautoInstallBundle -Daem.host=localhost -Daem.port=4502

After bundle installed, next steps should be performed:

  1. Create system user, grant required permissions to it and configure it for the bundle com.taradevko.aem.seo:

Grant user permissions

User mapping

  1. Configure service Canonical Tagging Support (pid com.taradevko.aem.seo.service.CanonicalTaggingImpl). Via Web Console/sling:OsgiConfig:

AEM Canonical Configuration

Rule has next syntax:

  • for strict rules, where page is mapped to another page: _PATH PAGE 1_=>_CANONICAL PAGE PATH_
  • for rules which map pages by regex and provide lookup path: _PATTERN FOR PAGE WHICH CHILD WILL BE MAPPED_>_LOOKUP PATH_
  1. Add canonical tag to your . To do this: insert next code into the required place:
          <link
              data-sly-use.canonicalTagging="com.taradevko.aem.seo.CanonicalLinkModel"
              data-sly-test="${canonicalTagging.hasCanonicalPage}"
              rel="canonical"
              href="${canonicalTagging.canonicalUrl}.html" />
    
  2. Make sure, that externalizer is configured. Also, you can additionally configure URL Mappings in Resource Resolver Factory, to omit some part of the path in URL.

AEM Externalizer Configuration

AEM Resource Resolver mapping

Examples

Page structure:

AEM SEO Example structue

Having configuration and structure, how it is shown above, we will get next results:

  • strict rule

AEM SEO Canonical Strict rule

  • pattern rule

AEM SEO Canonical Pattern rule

  • pattern rule with url mapping

AEM SEO Canonical Pattern rule with url mapping

LICENSE

The Apache License (Version 2.0, January 2004).

You can’t perform that action at this time.