$100 Website Offer

Get your personal website + domain for just $100.

Limited Time Offer!

Claim Your Website Now

How to load Common Menu to bulk html websites

You can simplify your menu management across thousands of static HTML pages by using JavaScript or server-side includes. Here are a few methods:


Method 1: Use JavaScript to Load a Common Menu

You can create a separate file (menu.html) that contains your navigation menu and use JavaScript to include it in all your pages.

Steps:

  1. Create a file named menu.html and add the menu code inside it: <ul> <li><a href="/about-us/about-us.html" target="_blank">About Us</a></li> <li><a href="/about-us/vision.html" target="_blank">Vision</a></li> <li><a href="/about-us/ecare-planet-technology.html" target="_blank">eCarePlanet Technology</a></li> <li><a href="/contact/join-hospital-network.html" target="_blank">Join Hospital Network</a></li> <li><a href="/about-us/disclaimer.html" target="_blank">Disclaimer</a></li> <li><a href="/about-us/services-easy.html" target="_blank">Simple & Easy Process</a></li> <li><a href="/about-us/services-full-service.html" target="_blank">Services</a></li> <li><a href="/about-us/services-quality.html" target="_blank">Services Quality</a></li> <li><a href="/about-us/services-savings.html" target="_blank">Services Savings</a></li> <li><a href="/about-us/services-guarantee.html" target="_blank">Services Guarantee</a></li> </ul>
  1. Include it in all HTML pages using JavaScript: Add this code inside the <body> where the menu should appear: <div id="menu-placeholder"></div> <script> fetch('/menu.html') .then(response => response.text()) .then(data => document.getElementById('menu-placeholder').innerHTML = data) .catch(error => console.error('Error loading the menu:', error)); </script>

Advantage: Any updates made in menu.html will automatically reflect on all pages.


To fix the href path issue when including the same menu across different directories, you should use absolute paths or base URL settings. Here are two approaches:


Solution 1: Use Absolute Paths

Instead of using relative paths, use absolute paths based on the root (/).

Example: Change your menu links like this:

<ul>
    <li><a href="/about-us/about-us.html" target="_blank">About Us</a></li>
    <li><a href="/about-us/vision.html" target="_blank">Vision</a></li>
    <li><a href="/about-us/ecare-planet-technology.html" target="_blank">eCarePlanet Technology</a></li>
    <li><a href="/contact/join-hospital-network.html" target="_blank">Join Hospital Network</a></li>
    <li><a href="/about-us/disclaimer.html" target="_blank">Disclaimer</a></li>
    <li><a href="/about-us/services-easy.html" target="_blank">Simple & Easy Process</a></li>
    <li><a href="/about-us/services-full-service.html" target="_blank">Services</a></li>
    <li><a href="/about-us/services-quality.html" target="_blank">Services Quality</a></li>
    <li><a href="/about-us/services-savings.html" target="_blank">Services Savings</a></li>
    <li><a href="/about-us/services-guarantee.html" target="_blank">Services Guarantee</a></li>
</ul>

Why?

  • Absolute paths (/about-us/about-us.html) will always resolve from the root domain, no matter where the page is located.

Solution 2: Use a <base> Tag in <head>

If you prefer to use relative paths, you can define a base URL in the <head> of every page.

Steps:

  1. Add this in the <head> section of your HTML files: <base href="https://www.yourwebsite.com/">
  2. Keep your menu links relative, but they will now always refer to the root: <ul> <li><a href="about-us/about-us.html" target="_blank">About Us</a></li> <li><a href="about-us/vision.html" target="_blank">Vision</a></li> </ul>

Why?

  • The browser will automatically resolve all links based on the <base> URL, even if you’re in a subdirectory.

Final Recommendation

  • If your website is static and follows a strict folder structure, use absolute paths (/about-us/about-us.html).
  • If you have a dynamic or multi-domain setup, use the <base> tag to simplify URL management.

Either of these fixes will ensure that your navigation menu works correctly across all 1000+ pages. 🚀

Related Posts

Navigating Legal Care in India: How to Evaluate Advocates, Practice Areas, and Consultations

Introduction Facing a legal question, business compliance issue, or court dispute can feel overwhelming. Whether you are dealing with a property transaction, a family dispute, an employment…

Read More

Navigating International Dental Care: How to Evaluate Hospitals, Dentists, and Treatment Abroad

Introduction Choosing a dental provider is one of the most critical health decisions a person can make, especially when considering travel outside one’s home country. Today, millions…

Read More

Navigating Modern Indian Taxation, Business Compliance, and Strategic Financial Advisory

Introduction Managing personal finances, scaling a startup, or running an established corporate enterprise in India requires strict adherence to an evolving regulatory landscape. From seasonal tax updates…

Read More

Navigating the Modern Event Ecosystem: Event Discovery, Digital Ticketing, and Management in Bangalore

Introduction Bangalore—often celebrated as India’s Silicon Valley and cultural melting pot—pulses with non-stop energy. On any given day, thousands of working professionals, students, creators, startup founders, and…

Read More

Evaluating Business Software, AI Platforms, and Enterprise Technology Solutions

Introduction The modern enterprise software ecosystem is expanding at an unprecedented rate. From cloud-native SaaS applications and AI-driven workflow engines to complex infrastructure management frameworks, technology leaders…

Read More

Enterprise AI Training and Certification Guide for Modern Professionals

Introduction Artificial intelligence has rapidly evolved from an experimental sandbox project into a fundamental core infrastructure requirement for global enterprises. Organizations across every sector are no longer…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x