Perform something before build

I am making a node express app and want to dynamically add OGP (open graph protocol) to different html files by executing some js code before the build happens. The app is sort of a blog website with different articles and I am using heroku for deployment. How can I do this?

You’re serving HTML with the express server, right? You’d just need to insert the right meta tags in the head before sending the response.

How? fs module does not have anything like the DOM api and cheerio is more of a web scraper. Will ejs do the job?