Search code examples
htmltemplatesreusability

template head tag html *EAN


Currently getting used to using Express, Angularjs and Nodejs. Is it possible using these frameworks to create a reusable or template head tag section to use in multiple html files.

For example, head.html contains

<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>

and files file1.html and file2.html want to include the same head from head.html. Is it possible to achieve this using these frameworks? Are there any alternative/better solutions?


Solution

  • You can certainly do that but as far as I know you'd be looking at using a templating engine like Jade or Ejs.

    They have include statements where you just include it in the file.

    However if you are using Angular I don't see much of a point to do this at all. Angular will bootstrap your entire webpage from one document usually index.html or app.html it really depends on what you name it. This way that stuff will only ever load once.

    That way you don't actually need to include it in multiple files, it will all be included from the get go.

    Does that make sense?