9

I'm new to html and was wondering if there is a way to apply the same content to many html files at once.

For example, if I have many pages, but all those pages have an identical navigation side panel that contains links to all the other pages. Is there any way to change the contents of this side panel without changing it for each individual page? i.e. is there a feature that allows me to make this navigation panel in a separate file, then tell all my pages to include this navigation file?

I know a css file can control the format of many html pages - is there an analogy to this that can control the content of many html pages?

xdl
  • 1,040
  • 2
  • 13
  • 20
  • 1
    This is called a *[Content Management System (CMS)](http://en.wikipedia.org/wiki/Content_management_system)*. You could also use a publishing platform like [WordPress](http://wordpress.org). – Jared Farrish Dec 17 '11 at 23:36
  • 1
    (i)frames? ;) No really don't use it :) – PeeHaa Dec 17 '11 at 23:36
  • 1
    @PeeHaa - You're going to have to be more specific. – Jared Farrish Dec 17 '11 at 23:38
  • @JaredFarrish I don't get what a CMS has to do with 'include' like features. – PeeHaa Dec 17 '11 at 23:38
  • @PeeHaa - It's a method of managing content, of which paged content is one type. The simpler form would be a publishing platform like WordPress. – Jared Farrish Dec 17 '11 at 23:39
  • @JaredFarrish sorry I still don't get what does have to do with includes :P Might be just me though – PeeHaa Dec 17 '11 at 23:41
  • @PeeHaa - http://drupal.org/project/pages A page is a type of content, I don't know how else to explain it. Admittedly, a full-blown CMS is probably not necessary, but it's a common approach. – Jared Farrish Dec 17 '11 at 23:45
  • @JaredFarrish actually a common approach is `server side includes` which a CMS system may implement – PeeHaa Dec 17 '11 at 23:46
  • Check this SO question : http://stackoverflow.com/questions/18712338/make-header-and-footer-files-to-be-included-in-multiple-html-pages – O.Badr Nov 28 '16 at 00:23

4 Answers4

8

You can use PHP to do that. Write the HTML code in PHP file, then add include statement in your HTML. This saves you from having to write same code again and again specially for navigation, etc.

PHP manual explains it.

Hope it helps.

Subash
  • 6,462
  • 7
  • 40
  • 66
2

You can write the common content in javascript file and include it in your html pages using script tag:

<script src="YOUR_FILE.js"></script>

You can use an online HTML to Javascript converter like this one to generate you javascript code.

O.Badr
  • 2,045
  • 2
  • 20
  • 27
1

Server-side includes or server-side programming languages (like PHP, for example), are often used to do that. All pages just include a shared common file, which contains the common content.

JB Nizet
  • 633,450
  • 80
  • 1,108
  • 1,174
0
<?php
include(file with extension);

?>

You'd have to change your file extension that runs this code to DOT php

Cjueden
  • 1,200
  • 2
  • 11
  • 25