Search code examples
htmlcsshyperlinkhead

how do i insert code that appears on every page on a site?


i'm looking to take some html, mainly the navigation bar and code:

<div id="navbar">
        <ul> 
            <li><a href="">Buy</a></li>
            <li><a href="">Lookbook</a></li>
            <li><a href="">About</a></li>
            <li><a href="">Contact</a></li>

        </ul>
    </div>

and insert it on every page on a given site. how would i do this so that when i make changes it reflects on all the pages, so i don't have to copy and paste the changes on each page.


Solution

    1. Add a empty div on all pages.
    2. Create a common java script function that will insert the above html to those Empty div.
    3. Call that javascript function on all the pages.
    4. This method is good only if you are working with Static HTML pages without any server side script.