This does not work:
let template = document.getElementById("template");
const templateContentCloned = template.content.cloneNode(true);
document.getElementById("div1").appendChild(templateContentCloned);
document.getElementById("div2").appendChild(templateContentCloned);
document.getElementById("div3").appendChild(templateContentCloned);
<template id="template">
<p>Here is my paragraph.</p>
</template>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
But this does:
let template = document.getElementById("template");
const templateContent = template.content;
document.getElementById("div1").appendChild(templateContent.cloneNode(true));
document.getElementById("div2").appendChild(templateContent.cloneNode(true));
document.getElementById("div3").appendChild(templateContent.cloneNode(true));
<template id="template">
<p>Here is my paragraph.</p>
</template>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
Why? Why do you have to clone the node every time you want to use the template?