Friday, August 20, 2010

UK telephone regex for PHP

PHP regex for UK telephone number:
if(preg_match ('/^((\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/', $string)) {
//do whatever
}
Can't remember where I got this from, if I do I will post link.

Labels: ,

Wednesday, August 11, 2010

Should all web developers work in SEO first

First a little background about myself. I first learnt HTML back in 1999 and was immediately blown away by the instant results of it. You added a likely bit of mark up and boom you saw the results in your browser - images, headers, tables the lot. Some quick code and it was like you could paint with the text in a matter of minutes, for someone with zero artistic ability it was a great feeling to see your ideas rendered on a screen. Not that the designs were anything to get excited about, but it was enough to get me hooked in web design.

Anyways, after a few years playing around at university I thought it was high time I get myself a job in the field that I studied for. After being put in touch with a company through a friend in 2005 I was thrust head first into the wonderful world of SEO (Search Engine Optimisation).

A very large part of SEO centres on the construction of the web page. There are so many ways that you can build a web that it would take me about a thousand years to go through them all. This article really is a piece about how SEO can help make you a better developer through best practice.

This blog post is based around a site I took on from a client who had invested thousands of pounds in to a website and was getting very little traffic. He came to me as I had built a number of smaller sites for a mutual acquaintance that had performed very well in the search engines and asked me if there was anything I could do. I took a look at the website and while it had been developed to a very high standard, the optimisation was severely lacking. After going back to the customer, I asked the customer what happened and it was down to the project manager that was employed to manage the job wanting to over-engineer the site, thus bogging down the original developer. A large part of the blog is information, but I will, also add in the example of the rebuild, where I can. There are so many more SEO techniques you can employ in addition to what I mention below. This case study is more of what I did when I rebuilt and the main areas we concentrated. Further more, there was about 1,200 pages in the database, this information went largely unchanged when it moved to its new home, I mention this, because like with all tests, the monitoring of all elements and variables is essential. Please also note that HTTP 301 redirects were used to make sure that no links were broken and that the busiest pages were mapped to forward to their new home. Non-essential pages were mapped to the home page.

Page construction

One of the first things that I learnt was how the construction of page can affect the optimisation of a page. In the beginning of my own development I used the very common technique of using tables to create the pages layout (even now, people still use this method) rather than the current element and CSS approach that I use now. When I made the switch to developer, not only is easier to keep your design separate from your source code but also makes for a more optimised page. When Google crawls a page it's not interested in the font sizes of your text or what colour it is, it just cares about the content and how this content fits in to the grand scheme of how Google sees the web. Not that layout is the only important part of page. Page Elements, div tags, H1, H2 and all the other primary tags should be used to create the perfect web page. If you took this idea to the extreme, then only those developers who can create ultimate optimisation should create web pages. This is of course not true, but you can get my point which is when you work in SEO you learn best practice that will help you no end if you change career path and become a developer.

Using jQuery/JavaScript to help improve your page's content and or functionality

Let us look at another example; you want a fully functional and flashy slide down menu based at the top of your page. Or the customer wants to have a mission statement at the top of the page that whilst essential to the brand is not necessarily optimised text. A developer without this experience must put the HTML in to the page and think nothing more of it, whereas a person who keeps SEO in mind knows the most optimised text should be towards the top of the page. This us where the SEO primed developer would use jQuery or JavaScript to load the HTML in to the DOM instead. In this situation, we get the best of both worlds as we have our text at the top in terms of presentation and our Google read source code remains uncluttered and optimised.

Another area I would like to touch on is the URL structure of a website. A great many, many people have argued about URL structure and how it affects SEO, all I can do is talk about how it affected the site I rebuilt for my client. I took a look at the existing URL structure and it was based around a 6 folder deep directory structure, which would have been almost impossible for the Search Engines to crawl, especially as there were 1,200 pages spread amongst them. Whenever I build a site, I keep the site as simple as possible. The site now goes no further than 3 folders deep and each page links to its siblings so that each page had hundreds and hundreds of links going to it.

I have not created this entry to boast but is more of a case study of how well a site can do when developed even when it has been completely rebuilt with SEO in mind with some figures to back up the theory.

OK, here are some of the figures for the rebuild, figures post rebuild, figures pre-rebuild a few reminders of some of the facts:

Pages in site: 1200
Domain Age: 4 years
Months since rebuild (at time of writing): 5 months
Development Language used pre-rebuild: PHP
Development Language used post-rebuild: PHP
URL rewrites in place pre rebuild: Yes
URL rewrites in place post rebuild: Yes

Average Visits prior to rebuild per month: 1,500
Average Visits post rebuild per month: 8,200

Yeah, you read that right, the site has had a 550% jump in traffic since the rebuild and the customer is now starting money from, something he wished he had been able to do when he first had the site launched. Yes, the traffic is still not huge, but the 550% increase in traffic in only 5 months is certainly a step in the right direction.

In conclusion I'm not saying that it is essential to have 10 number of years in SEO to become a web developer but it is important to know how to create a well formed page in terms of optimisation. When you consider how competitive the Search Engine Results Pages are and considering it is the developer that will help you attain these positions - it becomes even more important that these developers know how important optimisation is when developing a website.

Labels: , , , ,