Update #1: My changes have been rolled into the current development version of Elgg, so they should be in the next release. So if you don’t want to implement these changes yourself, you should be ok waiting for the upgrade.
Update #2: The title tag for pages and files did make it into Elgg 1.5, but the blog title tag change got regressed somehow. If it was not an accident, then they did it on purpose. Either way, it is very amateurish in my opinion, which continues to be one of my complaints about Elgg. Anyway, you can still apply the fix below exactly as described, and it will work.
I’ve been writing about Elgg recently, and more importantly, how to improve it. I have said that Elgg needs some attention to SEO to be a serious solution. Even though Elgg developers have taken my suggestions recently, I couldn’t wait any longer and took it upon myself to dig into the Elgg source code.
My goal was to improve Elgg SEO by creating unique title tags within the content. I was able to create unique title tags for blog posts, pages and files, by adding the post title to title tag in the header, so that each title tag is formatted like this, “Site Name : Title.”
Here’s how you can do the same thing step by step.
To give your blog posts a unique title tag, go to mod/blog/read.php and uncomment line 38. Here’s how it should read.
$title = sprintf(elgg_echo("blog:posttitle"),$page_owner->name,$blogpost->title);
Now your blog post title tags should read, “Site Name: username’s blog: Post title.”
Next up is pages. To give your pages a unique title tag, go to mod/pages/view.php and insert this code on line 40.
$title = $pages->title;
Now your page title tags should read, “Site Name: Page title.”
Changing the file title tags was a lot harder, because there is not really a file view. You have to change it in the entity view. Up to this point, we have been modifying plugins files, which is fine because we are not modifying the core Elgg files. This means those changes won’t get erased by upgrading your Elgg installation.
But modifying the entity view requires modifying core Elgg files, so proceed at your own risk. To make the change, open up entities\index.php. Insert this code on line 40.
$title = $entity->title;
Modify line 57 to look like this.
page_draw($title, $body);
Then on line 60 insert this code.
echo $title;
Now your file title tags should read, “Site Name: File title.”
These were small improvements, but hopefully it will pay off in more search engine traffic to your Elgg site. I’ve submitted these changes to the Elgg code base here, here and here. Hopefully, the developers will consider integrating these improvements into the actual code.
I’ve tested this code, and it works. But I am not a developer, so if I’ve made any mistakes, I welcome suggestions for improvement. If this would be better done as plugin, I would love to have someone come up with an Elgg SEO plugin, as well.
We have managed to solve the above problem. Another SEO problem is that Elgg does not support meta tags either. Any thoughts?
“We have managed to solve the above problem. Another SEO problem is that Elgg does not support meta tags either. Any thoughts?”
I mean the description meta tags that appear on Search Engine Results page and equally important for SEO as title meta tag.
I suppose it wouldn’t be that hard to write a function that included the first 100 or so characters from the post and displayed them in the description meta tag.
The question would be whether or not to roll it into the core files or make a plugin. I’m not that familiar with how the plugins work or if it is even possible. Making a core change would be difficult as well as there are many types of content, blog posts, files, pages, etc. I’ll look into it. They rolled my title tags into the core version of Elgg so maybe they would add meta tags as well.
Me personally, I’m not worried about meta tags. I don’t think they are very valid in SEO anymore. Besides the title tags, I’m more worried about the content of the page.
Thanks Jonathan
much thanks jon! this was much needed. Hopefully Elgg will follow your need and give more control over Page Titles and Meta Tags through it’s admin interface!
Fixed the title tags. Thanks Jonathan
Hello, I ran a Go Daddy report and it says I have over 596 pages with title tag issues can you help me?