Chapter 3: Building an SEO Friendly Website
The SEO process starts with building your website as it should be optimized, so the search spiders can crawl it and index its content once it is published on the Internet. The SEO preparation steps include creating the website structure, ensuring easy crawling, establishing the correct links hierarchy, and avoiding any errors that might prevent search engine indexing.
Protect Website Images with .htaccess
Redirect Non-WWW Traffic to WWW
Scan Errors with W3C Markup Validation
Plan for an Optimized Website
You have to consider your SEO methods even before you start to build your website, because optimization affects every part of your website, including its design, development, functions, and structure. If you do not take the methods for optimizing website content and files, known as On-page SEO, into consideration early on, it may be difficult to optimize your website in the future because many of the On-page SEO relates to the website infrastructure itself.
User-Friendly Functions
It sounds strange to talk about usability as the term is more related to the design side of the site developing, but actually, it is very important because once visitors locate what they need on a website, they remain on the website for a longer time. If users are satisfied with the website, they will save it as a Favorite and return to it again. If they find your website hard to use and they cannot find information easily, you will never be able to keep them on the site, even if you use every possible SEO tactic.
URL Structure
When you build a website, you should name your HTML files so it is easy for the search engine to identify the keywords and the file categories. For example, if you have a page that talks about photography basic tips, you can name the HTML file basic-photography-tips.html, and visitors can reach it through www.sitename.com/basic-photography-tips.html. This can help search engines index the web page and display it for users when they type photography tips in the search field.
Website Design Structure
One of the important things to consider is the website design. The clean design with optimized images can load fast and search engines can crawl it faster than a website with large-sized images, which take a long time to load. Also, a flexible design that can be modified easily allows you to customize your website based on the SEO recommendations.
Website Navigation
Navigation is very important to search engines, and website pages should be linked to each other so users can easily reach any page on a website from the other pages on the site. A web page that does not allow you to navigate to other pages on the website is called a dead link, and dead links are a bad practice in the SEO industry. The best way to unify your website pages is to create a menu that is located on each web page that visitors can use to link to other pages within the website.
SEO Website Functions
When you build your website, you have to consider functions that help the SEO process. For example, you can add a section under each post or content area that tells users about related topics on the website. Then they can visit the content for the related topics and get more information. This can help increase your website page views and the time users spend on your website.
Create a Website Sitemap
The sitemap is an XML-based file that indexes the website’s links, images, and files. It should follow the same structure as the website. The sitemap file is usually named Sitemap.xml, Sitemap.html, or Sitemap.php and it is placed in the website server so the search engines can reach it directly by following the website link; for example, it can be www.sitename.com/sitemap.xml, where sitename.com can be your own website name. While you can create the sitemap manually, there are tools you can use to create a sitemap for your website without needing to learn how to write XML code, such as the free sitemap generator at www.xml-sitemaps.com.
Create a Website Sitemap
Type www.xml-sitemaps.com in your web browser and press
.
The XML Sitemaps website appears.
Scroll down to the form.
The XML sitemap form appears.
Type the website URL.
Click the Change frequency pop-up menu and select the website update frequency.
Click the Last modification date option (
changes to
).
Click the Priority option to select how the XML sitemap calculates the URL’s indexing (
changes to
).
Click Start.
The website XML sitemap is created.
Click the link to download it.
After downloading, you can upload the sitemap to your website server root folder.
Create a Robots.txt File
The Robots.txt file is a text document that informs the search engine spiders which parts of your website you would like to be crawled and which parts you do not want the search engines crawling. For example, if you have large source files, crawling them may overload the server and consume the search engine crawlers’ time indexing website files. You can create the Robots.txt file using text editors, such as TextEdit for the Mac and Notepad for Windows.
Create a Robots.txt File
Create a File
Click the Finder icon (
).
The Finder window opens.
Click Applications.
The installed applications appear.
Click TextEdit.app.
Note: For Windows users, you can click Start, click All Programs, click Accessories, and then click Notepad.
The text editor opens.
Type User-Agent:*.
Press
.
Type Disallow: /video/.
Press
.
Type Disallow: /sources/sources/.
Press
.
Click File.
Click Save.
The Save As dialog box appears.
Navigate to the location where you want to save the file.
Type a name for your file in the Save As field, or in the File name field if you are using Microsoft Notepad.
Click Save.
The file saves.
After you create the Robots.txt file, you need to upload the file to the server. Usually, the Robots file is uploaded to the main folder on the server using a technology called File Transfer Protocol (FTP). FTP applications upload files to the website server using the username and password the server administrator or hosting company provides. There are many FTP clients such as FireFTP and FileZilla along with the FTP URL.
Upload the File to a Server
Click the FileZilla icon (
).
Note: If you do not have FileZilla on your computer, you can download or install it from http://filezilla-project.org.
The FileZilla client appears.
Click the Site Manager icon (
).
The Site Manager appears.
A If your new site form is unavailable, you can click New Site to display it.
Type the FTP URL in the Host field.
Click the Logon Type pop-up menu and select Normal.
Type a username.
Type a password.
Click Connect.
The FTP folder on the server appears.
Click and drag the robots.txt file to the FTP side to upload it.
Using the Nofollow Attribute
The Nofollow attribute is an HTML snippet that is added to the hyperlink code that creates links in websites. The Nofollow attribute plays an important rule in SEO, especially in building links that impact the website rank. Usually, the links to external websites can reduce the rank of the website. Therefore, you use the attribute rel="nofollow" in your HTML code to tell the search engine not to follow this link and discard it when evaluating the website. You can type this code in any text editor, such as TextEdit or Notepad, and save it as an HTML file.
Using the Nofollow Attribute
In your TextEdit file, type <a href="www.sitename.com" rel="nofollow">Anchor Text</a> on the line following the <body> tags.
Note: For Windows users, you can write the code in Notepad.
Click File.
Click Save.
The Save As dialog box appears.
Navigate to the location where you want to save the file.
Type the name of the file in the Save As field, or in the File name field if you are using Microsoft Notepad.
Click Save.
An alert message appears.
Click Use .html.
The file is saved as an HTML file. You can view the file using your web browser.
Build an .htaccess File
The .htaccess file is uploaded to the website server to help you control the web server’s behavior. It can help protect your website from specific issues, such as accessing secured directories on the server and banning unwanted visitors from specific sources. You can upload the .htaccess file to the website’s main folder on the server or any other folder that you would like to apply .htaccess rules to. While the file has a strange extension name, .htaccess, you can create it by using any text-editing application.
Build an htaccess File
In your TextEdit or Notepad editor, type RewriteEngine On to enable rewrite of the search engine rules.
Press
.
Type RewriteCond %{HTTP_USER_AGENT} ^WGET [OR] to prevent retrieving information from your server.
Press
.
Type RewriteRule ^.* - [F,L] to rewrite the access rules.
The basic htaccess file is created.
Click File.
Click Save.
The Save As dialog box appears.
Navigate to the location where you want to save the file.
Type .htaccess in the Save As field, or in the File name field if you are using Microsoft Notepad.
Click Save.
An alert message appears.
Click Use ".".
After you save the file, you can upload the .htaccess to your server root.
Protect Website Images with .htaccess
You can use the .htaccess file to prevent others from linking to your website’s images. To do this, you add code to the .htaccess file, which allows images to link only from your own website. This code is RewriteCond %{HTTP_REFERER}!^http(s)?://(www.)?yourwebsite.com [NC], which allows only your website to link to the images with specific formats. These format are defined in the next code line: RewriteRule .(jpg|jpeg|png|gif|flv|swf)$ - [NC,F,L].
Protect Website Images with .htaccess
In the .htaccess file, press
after the RewriteEngine On line.
Type RewriteCond %{HTTP_REFERER}!^http(s)?://(www.)?yourwebsite.com [NC], replacing yourwebsite.com with your website name.
Press
.
Type RewriteRule .(jpg|jpeg|png|gif|flv|swf)$ - [NC,F,L].
The new rules are added.
Click File.
Click Save.
The Save As dialog box appears.
Navigate to the location where you want to save the file.
Type .htaccess in the Save As field, or in the File name field if you are using Microsoft Notepad.
Click Save.
An alert message appears.
Click Use ".".
Redirect Non-WWW Traffic to WWW
You may notice that some websites can be accessed by typing the website URL with the WWW or without it. For example, both http://www.sitename.com and http://sitename.com point to the same website. While this is true, search engines still deal with both in a different ways and give both URLs different ranking. This is why you need to redirect the traffic from the non-WWW to the standard WWW URL. This is known as a 301 Redirect, or permanent redirect. You can apply this 301 Redirect in the .htaccess file.
Redirect Non-WWW Traffic to WWW
In the .htaccess file, press
after the RewriteEngine On line.
Type RewriteCond %{HTTP_HOST} !^www.sitename.com14, replacing sitename.com with your website URL.
Press
.
Type RewriteRule (.*)$ http://www.sitename/$1 [R=301,L].
The new rules are added.
Click File.
Click Save.
The Save As dialog box appears.
Navigate to the location where you want to save the file.
Type .htaccess in the Save As field, or in the File name field if you are using Microsoft Notepad.
Click Save.
An alert message appears.
Click Use ".".
Work with 301 Redirects
Websites are updated regularly and website pages may change based on updates. When a web page’s location or name changes, search engines may not update this change and may still see the old name or path, which they interpret as website errors. In order to fix this, you need to manually use the 301 Redirect to redirect any traffic or search engine to the new web page’s URL. It is also important to do this when you want to move the website from one domain to another without losing any traffic or affecting your ranking. You can apply the 301 Redirect from the .htaccess file.
Work with 301 Redirects
In the .htaccess file, press
after the RewriteEngine On line.
Type Redirect 301 /oldwebpage.html http://www.sitename.com/newwebpage.html, replacing oldwebpage.html with your web page’s old name, and replacing the sitename.com/newwebpage.html with the new web page URL.
Press
.
Type RewriteRule (.*)$ http://www.sitename/$1 [R=301,L]. The new rules are added.
Click File.
Click Save.
The Save As dialog box appears.
Navigate to the location where you want to save the file.
Type .htaccess in the Save As field, or in the File name field if you are using Microsoft Notepad.
Click Save.
An alert message appears.
Click Use ".".
Scan Errors with W3C Markup Validation
When you build your website and update it, your code may include errors or it may not follow web standards. Although these errors are not obvious when you test your website, it is important to check for them and try to have as few of them as possible. Clean code that follows web standards helps the search engine spiders crawl your website quickly and index its pages more efficiently compared to code that is not compatible with the web standards. There are many ways you can check website code compatibility; one is the W3C Markup Validation website.
Scan Errors with W3C Markup Validation
Type http://validator.w3.org in your web browser.
Press
.
The W3C Markup Validation Service home page appears.
Type the website URL.
Click More Options.
The More Options section expands.
In this section, you can select options to run a more detailed check.
Click Check.
The website error results appear.
Scroll down to see the errors.