# htp on-line reference : Including

## How to put common parts in different files

When you have a web site consisting of several pages, you may notice that you often need to add the same html code to all pages. With htp you can put common code in extra files and include them in all pages. Here is an example.

`1. <set title="htp file include example">
2. <file include="header.hti">
3. <h2>Here is the content</h2>
4. <p>
5. As you can see the file contains almost only the contents.
6. </p>
7. <file include="footer.hti">
`

In line 2 the `file`</file> tag is used to include a different file. When this tag is processed, htp will read and process the file header.hti (see below) and after it is finished it continues after the tag. The included file contains the usual html header and the navigation bar. All macros defined before the `file include` tag are also visible in the included file. So the macro `title` defined in the first line is used in the header to produce the title of the page:

`1. <html>
2. <head><title><use title></title></head>
3. <body>
4. <table>
5. <tr><td>
6. Navigation bar<br>
7. <a href="main.html">Main</a><br>
8. <a href="example.html">Example</a><br>
9. </td>
10. <td>
`

Similarly, in the last line of our example the file footer.hti is included, which contains the common copyright information and the necessary closing tags:

`1. </td></tr>
2. </table>
3. <hr>
4. Copyright by <a href="mailto:webmaster@domain.com">Joe Doe</a>.<br>
5. last updated <file date>
6. </body>
7. </html>
`

In the next section, we will show you a similar mechanism, the template.

hosted by Sourceforge HTML coding

Copyright © 1995–96 Jim Nelson. Copyright © 2001–2014 Jochen Hoenicke. Permission to reproduce and distribute this hypertext document granted according to terms described in the License section. last updated Sat May 16, 2015