Jack Fraser Jack Fraser - 5 months ago 11
Node.js Question

How can I change the html title of my main.hbs file from a partial.hbs?

I am trying to change my html title depending on the partial that I load for the body.

Parent html:

<!DOCTYPE html>
<html lang="en">
<head>
<title>
{{title}}
</title>
</head>
<body>
{{>body}}
</body>
</html>


Partial body.hbs file:

<h1 id="brick-mason">Brick Mason</h1>
<h3 id="what-is-a-brick-mason-">What is a brick mason?</h3>
<p>Brick masons use various stones, concrete and bricks to build walls, walkways, fences, and other structures.</p>


What can I change so that my partial can determine what the
title
on my main html page displays?

Answer

you can do it easily with JavaScript,

just add in the body.hbs :

<script> document.title = 'the title here ' </script>
Comments