preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Lack of documentation around adding meta tags info in template.html

Open lego-sharat opened this issue 4 years ago • 1 comments

My requirement was to add meta tags, so that when sharing links on twitter/fb/whatsapp a link preview should appear. I needed to add meta tags for this purpose. There is not a lot of documentation around that. Two things which are mentioned are preact-cli uses ejs and template.html has preact.title for dynamically showing title. Other than that, I couldn't find anything. I was able to figure out a solution by looking at the source code of the preact documentation site, where something like this is being used <%= htmlWebpackPlugin.options.CLI_DATA.preRenderData.description %>. So my questions are :

  • Is this the recommended way to add meta tags in a prect-cli project?
  • If no then what is the recommended way?
  • If yes then, is there any other data is useful which is being exposed like this and where should I look for that(this is for my own learning)

Also, I am willing to add the necessary documentation for this if but advance warning I don't have a lot of knowledge on html-webpack-plugin.

PS: Apologies if I have missed some obvious place which has the documentation And thanks for making this really useful framework

lego-sharat avatar May 17 '21 08:05 lego-sharat

Sorry, could use some extra docs there, but feel free to add.

If you look, preact-www uses preact build --prerenderUrls src/prerender.js ... as its build command, which leads here.

preRenderData.description isn't something that is exposed automatically, as it's coming entirely from that prerender script.

You can make your own script to generate whatever values you need.

rschristian avatar May 17 '21 16:05 rschristian