SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast Uphoreum's Avatar
    Join Date
    Jul 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Include HTML From a File?

    If I have several pages on a site, and part of them is always the same, can I put the html for that part in a file so that I don't have to update each one individually if I update it all?

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Yes, but you have to use a server-side language to do it. HTML by itself doesn't have this kind of functionality by itself.

  3. #3
    SitePoint Enthusiast Uphoreum's Avatar
    Join Date
    Jul 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I know php, so how can I do it that way? Or should I repost in the PHP section?

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Use include()

  5. #5
    SitePoint Enthusiast Uphoreum's Avatar
    Join Date
    Jul 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aha! Thanks!

  6. #6
    SitePoint Enthusiast myinnet's Avatar
    Join Date
    Jul 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you also can use Javascript, But that's not good for SEO

  7. #7
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by myinnet
    you also can use Javascript, But that's not good for SEO
    JavaScript is bad for includes in general. Why use a technology someone can turn off when you can do it on the server and have it work for everyone?

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by myinnet
    you also can use Javascript, But that's not good for SEO
    It's not good. Period.

    (For includes, that is.)
    Birnam wood is come to Dunsinane

  10. #10
    SitePoint Zealot
    Join Date
    Jul 2005
    Location
    Osoyoos BC Canada
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We've just been discussing this in the CSS forum. Take a look at my posts towards the end of the thread for instructions. No php or javascript needed.

    Why don't my includes appear?

  11. #11
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    server-side includes

    Quote Originally Posted by colinmcc
    No php or javascript needed.
    Yes, using Apache to parse includes is an option. (I imagine this could be done with cfm, jsp, pl and other ways too). The only potential problem I see with using Apache to parse the files is the hit to the server resources.

  12. #12
    SitePoint Zealot
    Join Date
    Jul 2005
    Location
    Osoyoos BC Canada
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is why apache is normally set to not parse files with type .html and only parse files with .shtml

    So as long as pages without includes are saved as .html the server hit is minimized.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •