In this post I will show you how you can SEO optimize your Liferay portlets. When you are building a portal which is (partially) available to the general public you want the search engines to rank your portal as high as possible in order to draw as much traffic to your portal as possible. Because of the nature of a portal (a ‘empty’ canvas filled with several unrelated portlets) it’s pages aren’t ideal for search engines because it hasn’t got a SEO description and keywords (or even a SEO friendly title).

In this post I will show you how you can in use build in features of Liferay to optimize SEO, First we will discus what you can do on a portal level and then I will show you how you can optimize SEO directly from a portlet itself.

Liferay Page Search Engine Optimization

In this section I will discuss the features Liferay provides to optimize SEO on a page level. First of all log in as (community) administrator on your portal. Navigate to the page you want to optimize. Click on ‘manage pages’ in the dock. You will now see the following screen:

You can use HTML title to specify the title of the page, you can use this field to change the title of the page in the HTML to something much more elaborate, the title of the for example menu item will not change.

When you expand the ‘Meta Tags’ tab you can specify (localized!) values for description and keywords.

Although this level of optimization is sufficient for static content, it wont react to the individual portlets displayed on the page: If you have a detail portlet for example you might want to extract keywords from it. In the next section I will show you how to achieve that.

Liferay Portlet Search Engine Optimization

In this section I will show you how you can optimize page SEO from inside a portlet, this is done using a Liferay specific API.  You can use the API from the com.liferay.portal.util.PortalUtil class. There are a lot of methods in this class but you only need a few of them to perform SEO optimization. Please take a look at the following documented code:

// Adds a title to the page
PortalUtil.addPageTitle("title", PortalUtil.getHttpServletRequest(renderRequest));
// Adds a subtitle to the page
PortalUtil.addPageSubtitle("subtitle", PortalUtil.getHttpServletRequest(renderRequest));
// Adds a description to the page
PortalUtil.addPageDescription("description", PortalUtil.getHttpServletRequest(renderRequest));
// adds a keyword to the page
PortalUtil.addPageKeywords("keywords", PortalUtil.getHttpServletRequest(renderRequest));
//Replaces the title of the page with this
PortalUtil.setPageTitle("title", PortalUtil.getHttpServletRequest(renderRequest));
// Replaces the subtitle of the page with this
PortalUtil.setPageSubtitle("subtitle", PortalUtil.getHttpServletRequest(renderRequest));
// Replaces the description of the page with this
PortalUtil.setPageDescription("description", PortalUtil.getHttpServletRequest(renderRequest));
// Replaces the keyword of the page with this
PortalUtil.setPageKeywords("keyword", PortalUtil.getHttpServletRequest(renderRequest));

I recommend that you make use of the addPage* function because you don’t know what other portlets will be on the page.

That is it for now. You can find a tutorial on how to create portlet SEO friendly URLs here.

Share and Enjoy:
  • Print
  • Twitter
  • LinkedIn
  • Digg
  • DZone
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • Technorati