SEO for Angulajs ajax loaded contents

faceFore

Generate XML Sitemap & Html internal links

Tweet


XML Sitemap is an important part of website SEO process. It helps to improve and speed up the site indexing,  by providing a clear list of the website's pages links to  search engine's crawler bot.

When search engine bot visits a website it first looks for a sitemap, if a sitemap exists then it follows the links presented in the sitemap, and crawls their contents.

Sitemap presents the complete architecture of a website and provides a road map of site's content to search engine bot. It is a good practice to create a XML sitemap of your site and submit it to Google and other search engines.

You can directly submit the sitemap to Google and Bing using their webmasters tool.

HTML Sitemap  is a Html file consists of  hyperlinks pointing to the website pages.  It  helps a lot in promoting the website links juice and improves the site authority. Google loves links, provide it clear and meaningful internal links.

Using website internal links properly, you can boost the website SEO. Here is what an internal link should contain.

Give  SEO friendly  names to your webpages, a descriptive anchor title and anchor text.  Contents of all the three should be relevant to the page subject.

Use the keyword in all of the three, make it more SEO friendly and relevant to the contents of the page. Do not use irrelevant  key words.

Script to generate XML sitemap and Html internal links

The script, given bellow will generate both the Html and  XML sitemaps. It will set the anchor title and anchor text to the page name. It will search for all the Html files in the given folder and will create Seo friendly Html anchor link for each.

If you are using our  tools for Ajax dynamically loaded contents, then it would have automatically  created a folder and stored all the static Html snapshots into it.

If you have given a descriptive  name to your pages then you will not need to edit it much, else it is better to edit the title and anchor text for Html anchor  links, to make it more meaningful.

If your website is built with Angularjs and having dynamically Ajax loaded contents, e.g. an eCommerce type of website, where page is generated dynamically for every product, then you can get our SEO Tools for Ajax loaded contents, which generates pre-rendered Html snapshot on fly and saves it intp a folder.

The Ajax SEO tools serves the Html snapshots to search engine crawler whenever it visits the website. So your website's every page has the chance to get crawled & indexed by Google and other bots.

You can type or copy & paste the following PHP code into a text editor and save it as a PHP file.  You can edit it to set the paths, if you have  folders with  different name. Upload it to your website root folder.  You can then type:

e.g.:  yoursite.com/thefile.php

into your browser address bar to generate the sitemap.  Generate sitemap whenever you have added new pages to the website.  It is simple and easy.

Remember to keep the sitemap.xml in you website root folder. You can divide the Html sitemap links in different files to include them in your website relevant pages.  But the better idea is to include up to 150 links in your index page as quick / direct links to your website pages, it will make it easier for crawlers to follow crawl the page contents.

------------------------------ The PHP script for generating sitemap ---------------------------

< ?php
// standard header for XML site map
$xml = '
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
';

// Gets the site name, e.g.: yoursite.com  .. you do not need to hard code it

$url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url = parse_url($url);
$url = substr($url['path'],0,strrpos($url['path'],'/')+1);
$site = "http://".$url;

$dir = "htmls/";     //  folder that contains Html files
//get all the  .html files
$files = glob($dir."*.html");
$links = '';    //for Html links
//build sitemap xml and site links
foreach($files as $filename)
{
$filename = substr($filename,0,strrpos($filename,'.'));
// if the sub-folder name is given in the glob function, else remark the below line
$filename = substr($filename,strpos($filename,'/')+1);  //extract the file name only

// use the below portion, if you are having Hashbang Urls
//$xml.=''.$site.'#!/'.$filename.'
$xml.=''.$site.$filename.'weekly1.00'."\n";
// create internal anchor link for the URL
$cap = str_replace("-"," ",$filename);  //caption or title for the link

// 
$links.='
'.$cap.' '."\n";
}
$xml.='';
file_put_contents('sitemap.xml',$xml);
file_put_contents('sitemap.html',$links);

echo nl2br("Done Sitemap XML....\n ".$site."\n");
print_r($links);

?>

--------------------------------- End of code ---------------------------------

I hope this script will help you. If you have any question, you can ask me.


Have a nice time,

Ayub
@facefore