jQuery Plugin To Generate Breadcrumbs From A Sitemap

jQuery Plugin To Generate Breadcrumbs From A Sitemap
File Size: 43.3 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A jQuery based breadcrumbs generator used to create an user-friendly breadcrumb navigation from a nested list based sitemap.

How to use it:

1. Create a sitemap that lists the web pages of your website.

<nav id="sitemaps">
  <ul>
    <li> <a href="index.html">Home</a>
      <ul>
        <li> <a href="sample/menu1.html">Menu1</a>
          <ul>
            <li><a href="sample/menu1-1.html">Menu1-1</a></li>
            <li><a href="sample/menu1-2.html">Menu1-2</a></li>
          </ul>
        </li>
        <li><a href="sample/menu2.html">Menu2</a></li>
        <li> <a href="sample/menu3.html">Menu3</a>
          <ul>
            <li><a href="sample/menu3-1.html">Menu3-1</a></li>
            <li> <a href="sample/menu3-2.html">Menu3-2</a>
              <ul>
                <li><a href="sample/menu3-2-1.html">Menu3-2-1</a></li>
                <li><a href="sample/menu3-2-2.html">Menu3-2-2</a></li>
                <li><a href="sample/menu3-2-3.html">Menu3-2-3</a></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</nav>

2. Create an empty list for the breadcrumbs.

<ol id="breadcrumbs"></ol>

3. Load jQuery library and the jQuery Breadcrumbs Generator on your webpages.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.breadcrumbs-generator.js"></script>

4. Call the plugin to automatically generate a breadcrumb navigation into the list container you just created.

$('#breadcrumbs').breadcrumbsGenerator();

5. Available options.

$('#breadcrumbs').breadcrumbsGenerator({
  
  sitemaps  : '#sitemaps',
  index_type: 'index.html'
  
});

6. Tweak the CSS styles to create your own styled breadcrumbs.

#breadcrumbs li { display: inline-block; }

#breadcrumbs li:not(:first-child) { margin-left: 0.4em; }

#breadcrumbs li:not(:first-child):before {
  content: ">";
  margin-right: 0.4em;
}

Changelog:

2017-05-17

  • v1.0.2: Fixed a reference to undefined variable `sitemaps`

This awesome jQuery plugin is developed by sutara79. For more Advanced Usages, please check the demo page or visit the official website.