开发者

Best way to use the same HTML on static web-pages

开发者 https://www.devze.com 2022-12-31 19:29 出处:网络
If you use dynamic pages like JSP or asp.net, you can have your page template included, and then content added. But what if you have no server-side component and all pages are just HTML/JS? You can of

If you use dynamic pages like JSP or asp.net, you can have your page template included, and then content added. But what if you have no server-side component and all pages are just HTML/JS? You can of course create a template then copy it for each page, but then if you want to change something you risk having to modify every page, even if you put most styling in CSS properly.

Are there any non-awful ways to do this? I could see that an iframe could be used to load the content into the central page but that sounds开发者_运维知识库 nasty. Does HTML provide any way to include a base file and add to it?


You can use Server Side Includes to include other files on the server. It's similar to scripting languages like ASP or php, but SSI is usually supported by the server directly, so it's available on many servers, even if there is scripting language available.


The answer is still templates. Just process them offline instead of on the server. I like to use ttree for this.


You can create the pages offline and render into HTML, and deploy those to the site.

One option might be: https://github.com/thewml but it does feel ... "too much". I also saw asciidoc for creating sites ( https://asciidoc.org/ ) and I also used several times doxygen for that ( http://www.doxygen.nl/ ).

I also saw CMS that create static HTML files, but hey are no longer maintained.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号