user2371684
user2371684

Reputation: 1555

Set HTML page title with js and pug

Is there a way to add to the page title with js and pug, if I for example have a layout file with pug, which sets the page title to, say Aero -

And in the pug file extending the layout file, I want to append a string to that page title with something else, so it would display Aero - The added string.

Is this possible with some sort of interpolation?

Upvotes: 3

Views: 2655

Answers (2)

thibautj
thibautj

Reputation: 76

You can do something like that:

 title Aero #{addedString}
 meta(name='description', content="Aero" + addedStringDescription)
 meta(property='og:title', content= "Aero" + addedString)

Upvotes: 1

HGomez
HGomez

Reputation: 1534

You can try using the block append functionality of pug.

In the layout.pug:

html
  head
    block head
      title= 'Aero'
  body
    block content

In the template.pug:

extends layout.pug

block append head
  title= title + 'The added string'

Upvotes: 1

Related Questions