Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat same HTML code in several pages

I have a really hard time searching for this, because I have no idea how to call it.

I'll try to describe the process I want, and see if any of you know such an editor. I have a website that has the same html component repeated in them, for example, a menu. I can define how the menu looks with css, but I can't (as far as I know) add the same piece of html to every html page with a simple line. What I do, is copy the menu over to every place. If I change the menu, I need to do it all again. I know this can be achieved by using a dynamic server, with something like php or jsp, but I don't need it to be dynamic.

I was wondering if there was a way to do this. I thought possibly there was an editor, where I can edit html using includes, and then "compile" the htmls after modification to produce the htmls I will replace on my server.

Thanks

like image 804
poet Avatar asked Jun 28 '12 08:06

poet


People also ask

How do I use the same HTML code on multiple pages?

You can store one or more of your JavaScript scripts in a single . js file and access them from multiple HTML pages. Put the script in an external JavaScript file. If you have the script already inside your HTML page, remove all the JavaScript code inside the <script> tag and paste it into a separate file.

How do you repeat content in HTML?

Use the <span> element instead. There's no <repeat> tag in HTML, unless you use JavaScript to create such an element in order to select that in CSS.

How do you repeat tags?

Repeat tagging on a single document, duplicate, or email thread. To repeat-tag* a document, you will first tag or untag the desired options and proceed to the next document.

How do I make HTML code not repeat?

To make a background image not repeat in HTML, specify no-repeat in the background-repeat property or the background shorthand property. The background image is set to 'no-repeat' using the 'background-repeat' property.


2 Answers

Have you heard about MasterPage Concept

The below link will give you a quick start

Master page are pages which will act as a frame for all other pages. You have to write it only one. And each page that is coming under that, will have to include the master page. Thats all!

like image 25
madhairsilence Avatar answered Sep 28 '22 14:09

madhairsilence


Have a look at server side includes ... create a menu.shtml page and then include it like so :

<!--#include virtual="/menu.shtml" -->

Its supported by most web servers out of the box (including IIS, Apache and lighttpd)

like image 129
Manse Avatar answered Sep 28 '22 13:09

Manse