Overview of Search Engine Optimization for Gallery2
I hope this is a starting point for those that want to make Gallery2 more SEO. Please remember that the SEO doesn’t make you show up higher in search listings, but makes it easier for this to happen. Having other people link to your pages is always the best thing you can do (at least for Google). Any additions to this list would be helpful. If you have questions or would like clarification, please ask.
Technical Background on Gallery2
Some of the suggestions on this list involve editing template and class files, do this at your own risk. Gallery2 administrators recommend copying the file you are editing to the subdirectory called “local” and editing the file there. Gallery2 will then use that file instead of the original. This also means that upgrades will not overwrite your edited file. In the examples below, I am using Gallery 2.2.3.
1. Activate URL Rewrite plugin
Read through the URL Rewrite Administration page and familiarize yourself with the structure of Gallery2, you’ll notice that the permalink of a photo is based on the filename.
2. Make items in keyword and other dynamic albums point to item’s permalink
ll links that can, should point to an item’s permalink–after all that is the valuable content–all else is for the user’s convenience and experience. This will eliminate some duplicate content and use the keyword album’s PageRank to point to the item’s permalink.
- On the Site Admin page, go to Keyword Album (and/or Dynamic Albums)
- Change Thumbnail links in dynamic albums to Jump to original album, and click Global checkbox if possible.
3. Use keywords in filenames
ince the permalink of an item is based on the filename, the filename of the item affect the keywords contained within the URL. Do not use the file name that a camera gives each photograph, but name your photos using keywords. You can do this manually, or you can use a bulk file renaming tool.
I recommend you use a bulk file renaming tool. On Windows, I use the free Bulk Rename Utility. It allows all sorts of file naming options including regular expressions, recursive file renaming of files in subdirectories, add suffixes, add prefixes and many, many more. It’s a little overwhelming when you first load the program. Thankfully, you can see the actual before/after of the file names, so you don’t have to guess at what you are doing. If anyone know of an OS-X bulk renaming tool, please contact me.
My naming convention for a file name is photo_set-photo_subset-people_or_objects. For a photo of my parents, my bride and myself at my wedding, I used wedding-party-rachel-stephen-richard-mary-james.jpg
4. Create keyword-dense titles and keywords for each item
aving tags or keywords link similar items not only provides users of your site to easily visit similar items, but it also links the keywords with your content for SEO.
Upon wanting to post over five hundred photographs of my honeymoon in Ireland to my Gallery2, I decided to write an automated PHP script that goes through the database and does the following:
- Reads in the file name
- Replaces the hyphens and/or underscores with spaces
- Removes Windows and OS-X renaming suffixes/prefixes such as numerals, parenthesizes and the word “copy.”
- Then, places this text in the item title field
After creating the title, I re-run the php script that then adds keywords. It does the following:
- Reads in the file name
- Replaces the hyphens and/or underscores with a comma and a space
- Removes Windows and OS-X renaming suffixes/prefixes such as numerals, parenthesizes and the word “copy.”
- Removes common words such as the, of, to , with, on, through, in and single letters (A-Z)
- Then, places this text in the item keyword field
Now you can do all this manually and probably get better results by fine-tuning each item’s keywords and title, but in this instance, I did not want to enter thousands of keywords and possibly misspell them.
If you would like a copy of this script, I can email it to you. Please contact me. You will need to directly edit a PHP file, but I believe it is straight forward enough. It has no warranty for anything it does to your system. Before using it, backup your database. After the script has run, the database cache will need to deleted at Site Admin >> Maintenance >> Delete database cache
5. Optimize robots.txt
Some say to disallow search engines from listing keyword or tag pages by using disallow within one’s robots.txt. The theory behind this is that search engines do not actually stop looking at the pages listed after a disallow command. Disallow is there to prevent good search engines from listing disallowed pages in their search results. They DO read and evaluate disallowed pages for content. So the theory is that when a user searches for a keyword, the keyword page will not show up in the search results, but the actual content pages that the keyword pages link to will show up. This only works with search engines that value linking over keyword density. Since there is usually not much text on an item page, disallowing keyword filled dynamic albums might have negative effects. I suggest you research optimizing your robots.txt more, before disallowing hundreds of pages from search engine results.
6. Remove slideshows
I would say that this is the least important item on this list, but you want to be sure to remove as much duplicate content as possible, then to remove the slideshow:
- Goto Plugins on the Site Admin page.
- Deactivate Slideshow and Slideshow Applet
7. Remove multiple sizes
I’ve never had multiple sizes setup in my Gallery, if someone has the directions on how to deactivate this. It would be helpful.
8. Enable Google Sitemap
Sitemaps are an XML document that lists all content pages. When your site changes, it changes. Just like it says, it is a map. It doesn’t automatically get you a higher SEO, it only give the search engine a map to browse your site with. Personally, I’m not convinced that this helps SEO. It just makes sure all your pages get listed–which if you are practicing good SEO on your site, when you should not have to worry about a page not being listed. To enable Google Sitemap:
- Goto Plugins on the Site Admin page and deactivate Slideshow and Slideshow Applet
- Activate Sitemap
9. Optimize permalinks
Search engines do not like variables (question marks and ampersands) at the end of URLs. Gallery is made to be sticky with its items which makes human browsing easier and pretty much eliminates the need to use the browser’s back button. If you use the breadcrumbs in the upper left to view a parent album, you are shown the album page that contains the item you were just viewing. Below are changes to make to the Gallery2 code
Comment out the urlParams call in /modules/core/classes/GalleryTheme.class
LINE 1408 - BEFORE
if (!empty($theme['parents'][$i + 1]['id'])) {
$urlParams['highlightId'] = $theme['parents'][$i + 1]['id'];
} else if ($itemId && ($i + 1) == count($theme['parents'])) {
$urlParams['highlightId'] = $itemId;
}
LINE 1408 - AFTER
/* if (!empty($theme['parents'][$i + 1]['id'])) {
$urlParams['highlightId'] = $theme['parents'][$i + 1]['id'];
} else if ($itemId && ($i + 1) == count($theme['parents'])) {
$urlParams['highlightId'] = $itemId;
} */
10. Make item titles into heading text and links
Add heading tags to item titles in /themes/matrix/templates/album.tpl (with “matrix” being your current theme)
LINE 121 - BEFORE
<p class="giTitle">
{if $child.canContainChildren && (!isset($theme.params.albumFrame)
|| $theme.params.albumFrame == $theme.params.itemFrame)}
{* Add prefix for albums unless imageframe will differentiate *}
{g->text text="Album: %s" arg1=$child.title|markup}
{else}
{$child.title|markup}
{/if}
</p>
LINE 121 - AFTER
<h2 class="giTitle">
{if $child.canContainChildren && (!isset($theme.params.albumFrame)
|| $theme.params.albumFrame == $theme.params.itemFrame)}
{* Add prefix for albums unless imageframe will differentiate *}
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">
{g->text text="Album: %s" arg1=$child.title|markup}</a>
{else}
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">
{$child.title|markup}</a>
{/if}
</h2>
11. Prevent duplicate base URLs for your Gallery
On Apache servers, you can change by each directory how the web server serves up your pages within a file named .htaccess. If you have implimented the URL Rewrite plugin correctly, then you should already have an .htaccess file in your Gallery2 directory. Redirects affect SEO negatively, and it has been said that two site homepages, /main.php and /, harm SEO. To prevent the 301 redirect to /main.php, add the following lines to the top of your .htaccess:
# Set the default handler.
DirectoryIndex main.php
It should be said that not all hosts allow you do change the DirectoryIndex. Also, this also might need to be done to get rid of “main.php” in the breadcrumb. I’m not sure if I changed this myself or gallery set it automatically, but on line 177 of /config.php, I have:
# Set the default handler.
DirectoryIndex main.php
In a related note, some search engines will differentiate www.yourdomain.com and yourdomain.com. This not good and could result in duplicate content. You can search Google via site:yourdomain.com and find out how your site is currently listed. You want to be listed in the same format that external links and internal links are linking to your site. To redirect pages without “www” to a page with the prefix, add the following lines to the top of your .htaccess:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
If you are hosting, your Gallery2 in a subdirectory (e.g.- photos), use this:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/photos/$1 [R=301,L]
12. Add META tags to your Gallery2 pages
It has been said that META tags have lost importance since their glory days ten years ago. They have lost importance to external links, but they are not to be disregarded. To add the META tags keyword and description to your Gallery2 pages add the following lines to /themes/matrix/templates/theme.tpl (with “matrix” being your current theme).
LINE 19 - BEFORE
{* If Gallery doesn't provide a header, we use the album/photo title (or filename) *}
{if empty($head.title)}
<title>{$theme.item.title|markup:strip|default:$theme.item.pathComponent}</title>
{/if}
LINE 19 - AFTER
{* If Gallery doesn't provide a header, we use the album/photo title (or filename) *}
{if empty($head.title)}
<title>{$theme.item.title|markup:strip|default:$theme.item.pathComponent}</title>
{/if}
<meta name="keywords" content="{$theme.item.keywords|markup:strip|default:$theme.item.pathComponent}" />
<meta name="description" content="{$theme.item.description|markup:strip|default:$theme.item.pathComponent}" />
Note: The above is only an addition of the meta tags.
13. Create SEO page numbers
This is related to number six, Optimize permalinks, but I have yet figured how to do it. I’ve read the Gallery2 forum thread, URL Rewrite for page number, but did not want to change my current item permalinks. If anyone has suggestions, I’d love to see this addressed.
-Stephen M. James
www.smjdesign.com You may view the latest post at
http://www.smjdesign.com/designwell/archives/add-seo-to-gallery2-search-engine-optimization/