How to apply the same content to multiple html pages

I am new to html and wondered if there is a way to apply the same content to many html files at the same time.

For example, if I have many pages, but all these pages have an identical navigation bar that contains links to all other pages. Is there a way to change the contents of this sidebar without changing it for each individual page? that is, there is a function that allows me to make this navigation bar in a separate file, and then tell all my pages about the inclusion of this navigation file?

I know that 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?

+4
source share
4 answers

You can use PHP to do this. Write the HTML in the PHP file, then add the include statement in your HTML. This eliminates the need to write the same code over and over specifically for navigation, etc.

The PHP manual explains this.

Hope this helps.

+4
source

Server-side or server-side programming languages ​​(e.g. PHP, for example) are often used for this. All pages include a common shared file containing shared content.

+1
source

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

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

You can use the online HTML code for the Javascript converter , for example this one , to generate javascript code for you.

+1
source
 <?php include(file with extension); ?> 

You will need to change the extension of your file that runs this code to dot php

0
source

Source: https://habr.com/ru/post/1386875/


All Articles