Actually I do not want to write a menu for each page of the site, and I want to find the best solution. A clearer solution is to display the content via iframe and change the source with a script (by clicking on the menu item). But many people complain about this method in the network, maybe there is a better option?

  • Depends on the structure of your site and the technologies used. The same code (piece of code) in each file is uniquely wild and not good. Usually, one common template is used for the site, for all pages, within which, in the content block, the content changes depending on the page. A cap, footer, connected resources and the rest of the "skeleton" pages remain constant. You can implement this with or without template engines (simple include in php, for example). - Ivan Pshenitsyn
  • I would like to do with html css and js. If it is possible. - Zhelez
  • one
    When using php, practically nothing will change, nothing will need to be rewritten at the root. All the necessary php-code, in this case, is reduced to a couple of lines of the type "include 'content.php';" - Ivan Pshenitsyn
  • 2
    @IvanPshenitsyn, the author of the question, besides html, uses js and he doesn’t have to drag php into the project, especially if he isn’t needed in a particular project. About the js template you can read here learn.javascript.ru/template-lodash . About iframe forget. - Ordman
  • one
    @IvanPshenitsyn, maybe the author raised the VDS and configured it for the project, although by the level of the question this is definitely not the case. Just do not want to use php, well, not necessary. - Ordman

2 answers 2

You can use the same gulp to build pages using, for example, jade

For this you need node.js , which uses js in its code, so you don’t have to learn a new language. But you will need to deal with node.js , gulp , jade )

Reference

  • I do not like the advice to use gulp and jade for a beginner, when the task is to simply insert the same menu on all pages. In the comments to the question sensibly advised -

You need a template engine. The code on the server that will take the templates of different parts of the page and assemble into a whole. Ready - MODx, but it is very easy to write your own.

You can’t do without a backend by preserving development literacy. SSI as the most leaky server technology does not count.

  • Eh, MODx - template engine? Something new ... Besides, as already noted in the comments - you can use template engines and on the client side. Do not be so categorical in your answer. - Ivan Pshenitsyn