Dynamic Meta Tag Content

After watching the incredible webinar yesterday, it dawned on me that I had not put any of the meta tag content discussed on my pages.

So, I went to the first page to add it and discovered that my favorite lightning icon wasn’t next to any of the entries.

As many pages are dynamic, I am not able to put static entries for description, title, etc.

Is it possible to do dynamic entries for the meta tag items in the App Structure?

I did do a search through the forum and the only thing I was able to find for a solution was coding it directly into the page.

Thanks

Click on App in App Structure, then choose Dynamic Attributes and Meta Tags

Guys,
It’s already possible to add dynamic meta tags to your pages. Select ‘App’ in the app structure, add new dynamic attribute and you will see the meta tags there, so you can bind dynamic data to them.

Sorry Teodor, I replaced my original answer with the correct one/

Right, I saw the description and keywords, but not the rest. (i.e. Open Graph and Twitter)

Unlike Google and modern search engines, Facebook and Twitter cannot read the dynamic meta tags added via app connect (they don’t read JavaScript values)
That’s why we’ve not added these in dynamic attributes.

Three years later, is this still true?

Is what true? :slight_smile:

Facebook and Twitter still not reading dynamic meta tags?

I need to set the meta tags for Facebook linking so am checking if this is still the case that Facebook and Twitter cannot read dynamic content. What’s the technique for addressing this?

Facebook and Twitter require your og:tags to be rendered on the server side. If you are using nodejs, you can use server-side rendering for that.
For other server models, you will need to write custom code as server-side rendering is not available.

I have used the PHP code solution in this post effectively in the past.
Could proably do with a bit of an update to use $_ENV variables to hide the login credential which could be exposed on server error but the solution does work.

1 Like

Thanks Brian.

How do you reference the $_ENV vars in PHP? I’ve tried $_ENV['db_user'] but it’s empty.

Hmmm, try checking ‘variables_order’ setting in your PHP ini file and make sure the setting includes an "E’ to define creation of $_ENV vars
Also check the output of getenv() from PHP which should list all $_ENV variables

Thanks Brian. Before I get myself into ini files, etc. Can you confirm the syntax for accessing env variables which are created in the Environment section of the server connect settings?

I used this PHP solution and it worked a treat.
One thing that Facebook seems to need is the image dimensions, so I had to add code to manage presenting that info too.

1 Like

I believe you are correct, I confess I have never used ENV variables on php platform.
<?PHP echo getenv(); ?>
Would be my first port of call.
(That’s the first line of php I have written on about 2 years!)
Otherwise probably need assistance from the oracle @patrick

That outputs nothing so I’ll wait for Patrick’s wisdom. :+1:

My understanding is which globals are supported is defined in variables_order in the php.ini file.
If not defined (no E in string) then ENV variables are not created. Then again I am no expert on this and am unsure how wappler creates and manages ENV variables internally.

Thanks Brian. I’m unsure about the link between Wappler environment variables and PHP ones, too, so Patrick is the one for this.

It would be lovely for Wappler to add the same Server-Side rendering for PHP just like they have for NodeJS. Then all this would be native stuff.

1 Like