I have an old pure HTML/CSS site that I want to clean up. I have two HTML pages that contain the same navigation bar. If I were using a framework like Django, I would extract that navigation bar HTML code into its own template (navigation.html) and then import that template using {% include 'navigation.html' %}
. Is there a way to do the same thing without using a heavy framework? At the very least, I don't want to use any server-side scripts.
Asked
Active
Viewed 196 times
0

Kent Shikama
- 3,910
- 3
- 22
- 55
-
I think you are referring to a JavaScript templating engine, such as nunjucks, handlebars... – sol Jan 10 '18 at 16:51
-
Could do it with vanilla JavaScript or jQuery or PHP. – Billy Moat Jan 10 '18 at 16:53
-
Can you provide more details for what you mean by a heavy framework? React/Angular don't require any server-side scripts. Handlebars is even smaller, but probably not future-proof. – V Maharajh Jan 10 '18 at 16:56
2 Answers
0
If you want to include a simple html file you can use HTML include
like so:
<head>
<link rel="import" href="/path/to/navigation.html">
</head>

mdatsev
- 3,054
- 13
- 28
0
You can try with this
$(document).ready(function() {
$('#some-menu').load('some-local-path/menu.html');
});

Pablo DbSys
- 532
- 1
- 7
- 17