Easiest way to maintain site-wide links?

Discussion in 'HTML & Website Design' started by pictureboarduk, Jul 11, 2009.

  1. #1
    Hi,

    I was wondering how I could update a site-wide link on my site.

    Instead of manually adding the link to each page separately, I was wondering how I could set it up so that I could edit the links in one location, and have have that change effect all the pages in my site.

    Kinda like how you have one external CSS file, and then just link to it in the code.

    These links need to be indexable, so using PHP or Javascript to display the links won't work.

    I'm sure there are tools in DreamWeaver etc, but I'm using Notepad.

    Thanks go to anyone who can suggest a simple solution!!!!

    Thanks!!!!!!!
     
    Solved! View solution.
    pictureboarduk, Jul 11, 2009 IP
  2. Phynder

    Phynder Well-Known Member

    Messages:
    2,603
    Likes Received:
    145
    Best Answers:
    0
    Trophy Points:
    178
    #2
    The solution is PHP. PHP will be indexable, but JavaScript will not. Just create a separate links.php file - add your links to that and then include the links.php file into all your pages. I leave the implementation to you as an exercise.
     
    Phynder, Jul 11, 2009 IP
    pictureboarduk and Kerosene like this.
  3. #3
    e.g

    Create links.php, containing something like:
    <a href="http://www.google.com">Google</a>

    Then paste this into your pages wherever you want the link(s) to appear.
    <? include "links.php"; ?>

    You'll either have to be using .php extensions on your pages, or fiddle with htaccess to make your .html or .htm pages parse php.

    It doesn't sound like much fun, but it's worth it :)
     
    Kerosene, Jul 11, 2009 IP
    Phynder and pictureboarduk like this.
  4. pictureboarduk

    pictureboarduk Well-Known Member

    Messages:
    551
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Awesome. Thanks very much!.

    I thought PHP may of made in un-indexable.
     
    pictureboarduk, Jul 11, 2009 IP
  5. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #5
    PHP is executed on the server - as far as browsers/spiders/bots are concerned, it's a hard coded document that you typed out yourself. :)
     
    Kerosene, Jul 11, 2009 IP
  6. pictureboarduk

    pictureboarduk Well-Known Member

    Messages:
    551
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    140
    #6
    It's working great now.

    Nice one :)
     
    pictureboarduk, Jul 11, 2009 IP
    Kerosene likes this.