a-ok Posted January 5, 2016 Share Posted January 5, 2016 Hi folks, Bit of an odd one... I'm adding some meta tags for Facebook and Twitter to the head.inc file and I'm trying to make the output per tag as global as possible. These are the tags I have so far: <meta property="og:title" content="<?php echo $page->title; ?>" /> <meta property="og:image" content="" /> <meta property="og:url" content="<?php echo $page->url; ?>" /> <meta property="og:description" content="" /> <meta name="twitter:url" content="<?php echo $page->url; ?>"> <meta name="twitter:title" content="<?php echo $page->title; ?>"> <meta name="twitter:description" content=""> <meta name="twitter:image" content=""> As you can see I have a few obvious ones set up, but I'm curious to know how you all might think about outputting the image and description meta information? I'm thinking finding the first image on the page and the first text output on the page but that's a little tricky, isn't it? Do you think these should be set up as separate fields for pages within the CMS for the client to fill out as they fill out the pages... as part of the process for SEO? And if there's any tips to why using these tags are bad please do say so. Many thanks, R Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 5, 2016 Share Posted January 5, 2016 I'd create a function, where you pass in the page and it returns the meta data. In the function I'd simply use a switch statement to change up the output depending on the template. With that you can have nice defaults, but also the option to customize when needed. 1 Link to comment Share on other sites More sharing options...
DaveP Posted January 7, 2016 Share Posted January 7, 2016 One easy addition to your original code is to add the descriptions, which would be something like $page->summary (per the default PW site profile). That said, you might want different descriptions (perhaps in tone, at least) across different social platforms. It gets even trickier with images as IIRC Twitter & FB don't agree on dimensions or aspect ratios. (Or at least they change them often.) FB's recommendations are here. Link to comment Share on other sites More sharing options...
Can Posted January 7, 2016 Share Posted January 7, 2016 With prependet template file (_init.php) and appended tpl file (_out.php) I got my defaults in the _init.php file but can override whenever I need it but just replacing it in a specifigpc tpl file like article.php for example Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now