Title is important to rank

May 2, 2010

One of the main keywords to my site did a bad ranking on google, so I tried to fix it.

It ranked on page 12-15 on a search – tested on a weekly basis. First off I tried to add the keyword into more noticeable places on the site, both inside the h1 tag, but also in text. That did not make any improvement at all.

Then I noticed that almost every result above had the keyword searched for in the title tag, so I put the word up there, and guess what? Now my site is at page 7 on that keyword… So, I conclude, title tag is very important for SEO.


Storing Images with PHP & Mysql – The right way

April 22, 2010

I’ve in that stage of my latest project that I have to decide how to store images to the server, and how to use the database the best way to do this. I know that I’ve done this wrong a couple of times, but hopefully I’ve find a good practice of this now. Not quite sure if this is the best way, but this is how I think after looking into the matter:

There are several things I consider to be important:
1. SEO.
The filenames need to be descriptive and searchable.
2. Database
Images should not be stored in the database, but the filename and id should. You need to know what image goes with what movie. It is possible to store images into database, but it makes the database big and I can image working with the images becomes little more complicated. There are advantages to this too, but it is not the way I’m going to do it.
3. Thumbnails
It’s a good practice not to resize in the <img> tag, so a good system for thumbnails must be at hand.
4. URI
Where to put the files is also something you have to consider carefully. Is it best to put everything in one folder? Probably not. What about “movie-id/images/image.jpg” or “images/movie-id/image.jpg”? Much better.

Let’s take an example database with four tables: Movie, ImageType, MovieImage and Image

Important part of movie is that it must have an id and a title.
Must have an id and a type, ex: cover, poster and screenshot
Realtionship between the movie, image and type. Contains the foreign key to image, movie and imagetype, where one of them has to be unique.
The image should have an id to the image so that it can be connected to a movie and made unique. In addition it should contain a filename, that is generated in php from the id, title of movie and type of image.

Cooking it all together:
The filename must be SEO optimized, so the syntax to use should be like: id-type-movie-name.jpg. You could remove the type from the name, but it’s a good way to distinguish between the different image types, making the SEO better too. Movie name should be separated by a hyphen to be most SEO friendly. By storing filename once with id instead of generating it every time and out from id, type and title is good practice because if the title is changed (from “Lord of the rings” to the more accurate “The Lord of the Rings: Fellowship of the Ring”) the filename points to the right file – id-type-lord-of-the-rings.jpg. Generating thumbs could then follow a standard of adding a -thumb-width-height or something to the name – or simply create it on the fly with a php method, even thou I think the first option is more correct. When getting all images to a movie you can easily sort by type, and get the filename from database – and then show it on your webpage by creating the correct url, ex: images/movie-id/1923-cover-lord-of-the-rings.jpg.

By thinking like this, the image uploading and storing become much more simplified for me than how I’ve done it before.

6 tips for better SEO & traffic when starting a website

April 16, 2010

I’m not an expert in the field, but I have noticed some factors that play a big part when starting to build your site. Some of this is something I’ve probably read or heard about, but most are own experience and I’ve not used similar articles as reference, so these are points I came up with on the fly when I started writing this post.

1. Time your posts right!
Depending on your audience, you should time new entries at times when people are online and can pick up your entry on feeds or twitter. If you know your target group is English-speaking and mostly from USA, then don’t add a post after midnight, because when traffic is peaking, your post is long gone.

2. Follow news & trends
When you post a news story, be one of the first with a proper story. This can make you the sources to others blog posts and even the one post that everyone retweet. This goes before the timing of the post, because news need to be fresh – and news are always googled by people who are interested in views and more information. Old news is never very good news. Be aware of what is trending – and include it in your writing and site.

3. Google ad words campaign
A great way to notify Google on the content of your site is to run an ad words campaign if you have $100-$1000 USD to spare. This is mostly in the beginning, to get targeted readers and audience, and to kick of Google attention to your site. I ran a 3 days campaign (with a free coupon I got from Google) on my small site and unique visitors a day rose with about 100%. It was not a very big site, so the traffic was not very big to begin with, but the effect was noticeable and stayed that way.

4. Begin ready
Have content ready to be published for a good time when you start. Don’t start twittering when site is up, start long time before to build up your followers, and then tweet about your site when it’s up. This way you are sure to get more traffic than if not. Have everything – every static page with carefully chosen words to get proper SEO. This includes unique header tags, titles on pages, about us page etc. Have some content pre posted on the site when start. If a blog, post a handful of good articles from the start (and keep them coming). This is, when Google and other search engines pick your site up they pick up all keywords and material thoroughly in first try. If you edit later you probably have to wait a while for Google to change the information on the static content, because Google are most interested in new content.

5. Advertise your site freely
Get out there. Be ready with Twitter, Digg, and other social media. Use them. Use forums, have link to your site in your footer. Post comments on relevant blogs and sites so that link to your site comes up. Tip relevant blog masters or news sites of your site, if they like, they may recommend. Link to articles and news that have a pingback function to get free advertisement. Advertise your site as a great site, not a “new site”.

6. Know how social media works and use them properly!
Tag your site correctly on delicious and more people will do the same by your suggested tags. Tag your site right in StumbleUpon and you get stumbled upon by the right audience.

How to set that title tag?

February 15, 2010

I’m in that place in developing my new site that I have to decide how I will manage the inclusion of pages, and there is a problem what I’ve really never bother about before. How to change the title tag in HTML the best possible way. This is a must for several reasons. First off, it makes the SEO(Search Engine Optimisation) better by giving a descriptive title to the page that show up in results. Secondly, most browsers now use tabbed browsing and to se on the tab what page it is you are on is a good thing.

Now, I have to tell that I do not use frameworks – mainly because I want to learn stuff myself first – so even thou they probably have implemented a good solution, I still need to fine one myself that will satisfy my needs and make the programming part good.

The problem might not be a big problem, but it is really a good example on why a good design should be implemented. The way I have done it before is simply to have one title for each page – because the title is in the header, and the header was an HTML file I included at the top of the php. Easy fix is to add some php that gets the page attribute from the url, and then does an if else on every page to give the right title. The problem is, this is an if else, or switch, that you then probably have to implement a lot of times in the code – for example to find out which menu item you are currently on – and makes the code unneccessary hard to read. The rule of making most of the logic in a underlaying architectural layer should apply.

So, the solution then? Well, I tell you my simple plan that is under developement.

I’m going to make the page a PHP Object, (pseudocode) like this:

$page = new Page($_GET['page']);

The “?page=user” is set in as an attribute to the page object. The same is done with the id=1, and other attributes if they exists. Then when the page is printed the header is put together.


printHTML() is using the self::getHeader and self::getBody to build the complete HTML wrapped in Should Body and Header be Objects too?
Should Footer, mainBody, navBar, Logo, sideBar be objects as well?

To be honest, I really don’t know how far I will make it – but I do se a pattern that every changeable part of the design should be objects – so that they can be built on they own. Especially Header, Body and sideBar(that is a part of the body). This is a bit out of scope right now, but the point is to make a design that is object-oriented right to the core, making the attributes on the object decide what HTML to include, and then present it the right way.

Back to the title, lets imagine we have a simple Page object with a simple all in one getHTML() function. This then contain the following simplified code:

return ''.self::getTitle().''.self::getBody().'';

The getTitle() function should do something like this:

$title = 'Sitename - '.$this->page; //User
$user = new User($this->id);
$user->get(); //Get the user from database
$title .= ' - '.$user->getName();
return $title;

This is not the code I’m going to use, it’s just to show the logic. I think this approach gives good practise in programming an OO(Object Oriented) way, and hopefully makes the site flexible too.

Does this make any sense at all?