1

I need to put some <meta /> tags in the <head /> section of the html document prior the rendering of the template. I would like to know how can I achieve this? I also need to query an external database in order to get some data from it and populate the meta tags. What I want to accomplish is to pass a link to my website and get Twitter to display a card with the image, description, etc.

What is the best option in order to accomplish this task? a Plugin? a Controller? a Module? Does anybody know any good tutorial or guide in order to do this?

I'm using CraftCMS ver 3.4.9

Thank you in advance for your support.

1

There's a plugin that allows you to connect to an external database, which will allow you to do a query within the template. Remember to cache the result though as it could slow things down otherwise.

Another option is to sync the external data with Craft using feed me, so you can pull the data locally.

2
  • What about to get the data first prior the template rendering? How do I get to do this? a Plugin? a Module? a Controller? Thanks! Aug 16 '20 at 15:37
  • Yes you can create a module with a controller that can render a template: craftcms.com/docs/3.x/extend/…
    – dmatthams
    Aug 17 '20 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.