[HTML] Identical content over multiple pages?

Discussion in 'General Webmaster Support' started by LurkerAspect, Mar 10, 2012.

  1. LurkerAspect

    LurkerAspect Now officially a Super Lurker

    +117 / 0 / -0
    Hi there :D

    I've recently started learning how to make websites with HTML and CSS for university/college, and I was wondering if it's possible to import a specific area of code that I can define outside the website, and use across multiple webpages? In other words, is it possible to create an external file with a few lines of code, then import that snippet of code into multiple web pages?

    Basically I'm making a website with 16 pages, and I don't want to have to modify the navigation bar's links for every single page, which means making about 16 links for 16 pages, which comes out to 256 links I'll need to type out/copy-paste.

    If you're still confused, I'll try to illustrate: Here's the code snippet:
    <div id="quicklinks">
         <a href="pg1">Home</a>
         <a href="pg2">Accomodation</a>
         <a href="pg3">Entertainment</a>
         <a href="pg4">Shopping</a>
    I want to be able to import this snippet so I don't have to write it out again on every single page. Is that possible?

    Any help is greatly appreciated :D
    • Like Like x 1
  2. UndeadDragon

    UndeadDragon Super Moderator Staff Member

    +450 / 0 / -0
    The best way will be, if your server supports PHP, to include the file everytime it is needed and then you will update the single file when needed, which will affect all pages it is included on.

    For example:

    <div id="quicklinks">
    a href="pg1">Home</a>
    a href="pg2">Accomodation</a>
    a href="pg3">Entertainment</a>
    a href="pg4">Shopping</a>

    <?php include "navigation.htm"?>
    • Like Like x 1
  3. LurkerAspect

    LurkerAspect Now officially a Super Lurker

    +117 / 0 / -0
    Thanks Undead Dragon, I'll give it a shot :D so far the website is not going live, it'll just be run locally for marking purposes so I'm sure the PHP won't be a problem :) Thanks for the speedy reply!

Share This Page