How to Create Sitemap - Make Sitemap Generator

How to make Sitemap or Sitemap Generator

People always search on google to generate sitemap for own website. There are two popular versions of a site map. An XML Sitemap is a structured format that a user doesn't need to see, but it tells the search engine about the pages in a site, their relative importance to each other, and how often they are updated. HTML sitemaps are designed for the user to help them find content on the page, and don't need to include each and every subpage.
            Here, I will not give information how to make sitemap but I will teach you how to make your own sitemap generator, So Web Developers can easily make sitemap.

 Lets Make your own Sitemap Generator

Follow below steps:

Step 1:
Make HTML file with name Sitemap.html
Here is code
 <!DOCTYPE html>  
     <title>Sitemap Ganerator</title>     
         <td width="200px">Enter links:</td>  
           <Textarea name="recommend" rows="22" id="txtOutput" cols="100"></Textarea>  
     <button id="DownloadButton">Create file</button>  
     <div id="generated" style="display:none">  
       <a href="#" id="DownloadLink">Download</a>  
       <textarea id="ResultXml" style="width: 100%; height: 30em" readonly="readonly"></textarea>  

Step 2:
Put below code before </head>. Its JS source files.
 <script src=""></script>  
 <script type="text/javaScript" src="sitemap.js"></script>  

Step 3:
Make JavaScript file with name sitemap.js
Here is code
 $(function() {  
       var template = [  
         '<?xml version="1.0" encoding="UTF-8"?>',    '<urlset',  
         '<!-- Code by Rakesh Patil, Protected with DMCA-->',  
       function update() {  
         var $root = $('<XMLDocument />');  
         $(document).ready(function() {  
           var arrayOfLines = $('textarea[name=recommend]').val().split('\n');  
           $.each(arrayOfLines, function(index, item) {  
                     $('<url />').append  
                         $('<loc />').append(item),  
                         $('<priority />').append('1'),  
                         $('<changefreq />').append('monthly')  
             var variables = {  
               'loc': $root.html()  
             var newXml = template.replace(/<\?(\w+)\?>/g, function(match, name) {  
               return variables[name];  
                 .attr('href', 'data:text/xml;base64,' + btoa(newXml))  
                 .attr('download', 'sitemap.xml');  
       if (!window.btoa) {  
       btoa = function (input) {  
       var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';  
           var result = '';  
           var chr1, chr2, chr3;  
           var enc1, enc2, enc3, enc4;  
           var i = 0;  
           do {  
       chr1 = input.charCodeAt(i++);  
           chr2 = input.charCodeAt(i++);  
           chr3 = input.charCodeAt(i++);  
      enc1 = chr1 >> 2;  
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);  
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);  
      enc4 = chr3 & 63;  
      if (isNaN(chr2)) {  
       enc3 = enc4 = 64;  
      } else if (isNaN(chr3)) {  
       enc4 = 64;  
      result += chars.charAt(enc1) + chars.charAt(enc2) + chars.charAt(enc3) + chars.charAt(enc4);  
     } while (i < input.length);     
     return result;  

Step 4:
Save all files in one folder and open Sitemap.html in browser. Done.
Now your own sitemap generator is ready to make sitemap for your website.
If any query or problem, free to ask via comment.
Note: Don't use above code to publish on website or blog.



Post a Comment