Wednesday, December 23, 2009

GWT SEO Title, meta description and keywords

GWT 2.0 provides a way of doing SEO by using HTMLUnit. Once GWT module is downloaded, the page is not refreshed, so title, meta description are not changed.

However, the page is changed with different token.

SEO required unique page tile, meta description and meta keywords (even though, it is said meta keywords are not used by Search engine anymore)

Here is the approach to change the page title, description and keyword with GWT.
1) Once get page history token, then get resource bundle content based on token, locale.
2) Create title, description string based on resource content and business objects if apply.

For title:
Window.setTitle(title);

For description:
final NodeList nodeList = Document.get().getElementsByTagName("meta");
rewriteMetaContent("description", description), nodeList);

private void rewriteMetaContent(
final String key, final String value, NodeList nodeList) {

if (nodeList == null) {
return;
}

for (int i=0; i Element element = nodeList.getItem(i);
if (key.equalsIgnoreCase(element.getAttribute("name"))) {
element.setAttribute("content", value);
return;
}
}
}

One thing needs to point out: SEO looks for DOM entry, not view source.
So if your HTMLUnit version and end user version of title, description are matched, it is good. Otherwise it is cloaking. Be careful for that.


No comments:

Post a Comment