clemdesign / grav-plugin-social-seo-metatags Goto Github PK
View Code? Open in Web Editor NEWPlugin for Grav CMS embed metatags management for Social and SEO
License: MIT License
Plugin for Grav CMS embed metatags management for Social and SEO
License: MIT License
Hi Clement;
I wonder if it's possible to define a description for a page
example:
I'm able to specify a description for twitter by adding
metadata:
'twitter:description': 'description for twitter'
but unable to do the same thing for <meta name="description"
I try both :
description: description generale
and
metadata:
'description': 'description generale'
Thanks for implementing the header_image_file
. However, the URL is not being set correctly. It just take the file name from the header. It should point to a full URL (https://domain.tdl/......custom_image_header.jpg
) in order to be valid.
Thanks for considering
Current behavior:
To define description
, twitter:description
and og:description
, each meta-tag shall be defined in header frontmatter like this:
metadata:
description: 'Description of page'
'twitter:description': 'Description of page'
'og:description': 'Description of page'
This operation is boring.
Expected behavior
Good deal is to avoid this repetition and define directly in frontmatter configuration the field description
which used if defined, like this:
description: 'Description of page'
metadata:
<other fields>
This solution keep compatibility for metadata overwritting.
On this grav site: http://istenieroforras.igehirdetes.ma/ the og image tag, etc. seems to be set right, gzip compression is disabled as it can be seen also from https://checkgzipcompression.com/?url=http%3A%2F%2Fistenieroforras.igehirdetes.ma%2F.
Why facebook won’t load any image for any of this site’s pages? No title, no images, nothing. What is wrong with this site? Tried to debug it with facebook’s tool, waited for weeks to change, these didn’t help.
I serve multiple sites on this server, and so I use a reverse proxy to mask the port number (nginx proxy_pass
). Works fine, except for this plugin does this
<meta property="og:url" content="https://blog.example.com:9093/philosophy/topic" />
instead of
<meta property="og:url" content="https://blog.example.com/philosophy/topic" />
Also it adds the port to og:image
and twitter:title
(Not sure how you're building the link but in PHP there's a difference between the various $_SERVER hostname vars, some with ports, some without, make sure you use the right one)
When trying to install via the plugin manager from the Grav Admin I get the following error:
Error while installing the package(s)
social-seo-metatags
Grav: v1.7.30
Admin Panel: v1.10.30.2
Hi. As you closed the later issue, I need to open this new one with the same title. I know you didn't like my PR after you asked to see it. As I said, not a PHP dev. Anyway, I find out a better way to fix this. In this line:
use this:
$antimatterFile = $page->path() . '/' . $page->header()->header_image_file;
That would fix the issue. Thanks for considering.
For example, a page with summary "SAN JOSE — Jonny Brodzinki is riding high on a huge wave of goals. He powered the San Jose Barracuda with two goals in a 5-1 convincing victory over the Iowa Wild on Wednesday evening at SAP Center." gets displayed as "SAN JOSE — Jonny Brodzinki is riding high on a huge wave of goals. He powered the San Jose Barracuda with two goals in a 51 convincing victory over the Iowa Wild on Wednesday evening at SAP Center." in Facebook and Twitter.
Of course, a "51 convincing victory" doesn't make a lot of sense.
It seems that the sanitizeMarkdowns
function is causing this problem.
I know there is a plugin already available but it is not working in my case, and If you will make this plugin like Yoast SEO in wordpress then this plugin will be like a full seo kit. THANKS For such a great plugin.
We are instructed to add this line
(config.plugins['social-seo-metatags'].enabled and config.plugins['social-seo-metatags'].social_pages.pages.facebook.enabled) ? 'xmlns:og="http://ogp.me/ns#"' : ''
to our "base template" -- please give more information. What and where is the base template? Is it part of my theme? Can it be edited from grav, or do I need to ssh into the server install? What is the exact path of this file?
One of my pages has an apostrophe in the title:
Roger's Books
and this ends up in the tags as '
It is the correct translation but it isn't right when twitter displays it because twitter leaves it at Roger's Books
The problem is in the social-seo-metatags.php file at the end of the sanitizeMarkdowns funtions. I changed the call to htmlspecialcharacters to use ENT_COMPAT rather than ENT_QUOTES and it worked fine. You might want to do something similar, or make it an option.
Hi,
I get the critical error "Undefined variable: path" on Grav 1.7.7 and the plugin version 2.1.0 .
The stack-trace is
/var/www/html/developers-t6/system/src/Grav/Common/Debugger.php(843): Whoops\Run->handleError()
/var/www/html/developers-t6/user/plugins/social-seo-metatags/social-seo-metatags.php(281): Grav\Common\Debugger->deprecatedErrorHandler()
/var/www/html/developers-t6/user/plugins/social-seo-metatags/social-seo-metatags.php(313): Grav\Plugin\SocialSEOMetaTagsPlugin->getDefaultImage()
/var/www/html/developers-t6/user/plugins/social-seo-metatags/social-seo-metatags.php(104): Grav\Plugin\SocialSEOMetaTagsPlugin->getTwitterCardMetatags()
/var/www/html/developers-t6/vendor/symfony/event-dispatcher/EventDispatcher.php(264): Grav\Plugin\SocialSEOMetaTagsPlugin->onPageInitialized()
/var/www/html/developers-t6/vendor/symfony/event-dispatcher/EventDispatcher.php(239): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()
/var/www/html/developers-t6/vendor/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
/var/www/html/developers-t6/system/src/Grav/Common/Grav.php(550): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
/var/www/html/developers-t6/system/src/Grav/Common/Processors/PagesProcessor.php(44): Grav\Common\Grav->fireEvent()
/var/www/html/developers-t6/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\PagesProcessor->process()
It seems like adding $path = null
in the beginning of getDefaultImage() solves it, but feels like it should have other side-effects as well.
Do you have any idea of what's going on? Thanks in advance!
Hi,
thank you for providing this plugin.
My plugin was automatically updated and is now throwing an error:
0 - Grav\Plugin\SocialSEOMetaTagsPlugin::getImage(): Argument #1 ($image) must be of type Grav\Common\Page\Medium\ImageMedium, null given, called in /var/www/html/xxx/user/plugins/social-seo-metatags/social-seo-metatags.php on line 326
Is there any migration needed for the new version?
Hi. Would it be possible to add an option to use cached images on the og:image
and twitter:image
? For example, I got it replacing
$image->url()
with
$image->cache()->url()
Thanks for considering.
NoArchive and NoODP can each be selected, but not together, in the drop-down list for the default. Adding this combined option would be useful.
Hi! I would like to suggest you to add some check if the page have the blog header image (header_image_file
) before getting the image list. I have made a very dirty solution here at the getFirstImage function (at line 231 of social-seo-metatags.php), but I am sure you could make a good implementation. With this, both twitter and og tags would use the header image if present.
Thanks for considering.
Hi,
after trying out 3.0.1 (because of #26) another error occurs:
Server Error
Sorry, something went terribly wrong!
E_WARNING - Undefined variable $image
For further details please review your logs/ folder, or enable displaying of errors in your system configuration.
[2021-11-09 08:43:01] grav.CRITICAL: Undefined variable $image - Trace: #0 /var/www/html/XXX/system/src/Grav/Common/Debugger.php(843): Whoops\Run->handleError(2, Undefined varia..., /var/www/html/m..., 364) #1 /var/www/html/XXX/user/plugins/social-seo-metatags/social-seo-metatags.php(364): Grav\Common\Debugger->deprecatedErrorHandler(2, Undefined varia..., /var/www/html/m..., 364) #2 /var/www/html/XXX/user/plugins/social-seo-metatags/social-seo-metatags.php(391): Grav\Plugin\SocialSEOMetaTagsPlugin->getDefaultImage() #3 /var/www/html/XXX/user/plugins/social-seo-metatags/social-seo-metatags.php(103): Grav\Plugin\SocialSEOMetaTagsPlugin->getTwitterCardMetatags(Array) #4 /var/www/html/XXX/vendor/symfony/event-dispatcher/EventDispatcher.php(264): Grav\Plugin\SocialSEOMetaTagsPlugin->onPageInitialized(Object(RocketTheme\Toolbox\Event\Event), onPageInitializ..., Object(Symfony\Component\EventDispatcher\EventDispatcher)) #5 /var/www/html/XXX/vendor/symfony/event-dispatcher/EventDispatcher.php(239): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, onPageInitializ..., Object(RocketTheme\Toolbox\Event\Event)) #6 /var/www/html/XXX/vendor/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, onPageInitializ..., Object(RocketTheme\Toolbox\Event\Event)) #7 /var/www/html/XXX/system/src/Grav/Common/Grav.php(564): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(RocketTheme\Toolbox\Event\Event), onPageInitializ...) #8 /var/www/html/XXX/system/src/Grav/Common/Processors/PagesProcessor.php(46): Grav\Common\Grav->fireEvent(onPageInitializ..., Object(RocketTheme\Toolbox\Event\Event)) #9 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\PagesProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #10 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #11 /var/www/html/XXX/system/src/Grav/Common/Processors/TwigProcessor.php(38): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #12 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\TwigProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #13 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #14 /var/www/html/XXX/system/src/Grav/Common/Processors/AssetsProcessor.php(39): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #15 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\AssetsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #16 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #17 /var/www/html/XXX/system/src/Grav/Common/Processors/SchedulerProcessor.php(40): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #18 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\SchedulerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #19 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #20 /var/www/html/XXX/system/src/Grav/Common/Processors/BackupsProcessor.php(39): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #21 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\BackupsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #22 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #23 /var/www/html/XXX/system/src/Grav/Common/Processors/TasksProcessor.php(69): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #24 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\TasksProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #25 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #26 /var/www/html/XXX/system/src/Grav/Common/Processors/RequestProcessor.php(63): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #27 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\RequestProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #28 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #29 /var/www/html/XXX/system/src/Grav/Common/Processors/ThemesProcessor.php(38): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #30 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\ThemesProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #31 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #32 /var/www/html/XXX/system/src/Grav/Common/Processors/PluginsProcessor.php(39): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #33 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\PluginsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #34 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #35 /var/www/html/XXX/system/src/Grav/Common/Processors/InitializeProcessor.php(130): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #36 /var/www/html/XXX/system/src/Grav/Common/Debugger.php(546): Grav\Common\Processors\InitializeProcessor::Grav\Common\Processors\{closure}() #37 /var/www/html/XXX/system/src/Grav/Common/Processors/InitializeProcessor.php(131): Grav\Common\Debugger->profile(Object(Closure)) #38 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(50): Grav\Common\Processors\InitializeProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #39 /var/www/html/XXX/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(62): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #40 /var/www/html/XXX/system/src/Grav/Common/Grav.php(303): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #41 /var/www/html/XXX/index.php(58): Grav\Common\Grav->process() #42 {main} [] []
This is the metadata on my page:
metadata:
author: 'Roger J Parkinson'
description: 'Discusses whether animals feel pain or is that an anthropological illusion.'
keywords: animals, neurons, emotion
This is the result:
<meta name="description" content="There was a piece in our local news feed about a vet who, among other things, maintained that animals do not feel pain. This idea comes up surprisingly often, what is unusual is that this time it is from…" />
<meta name="keywords" content="animals, neurons, emotion" />
<meta name="author" content="Roger J Parkinson" />
<meta property="og:description" content="There was a piece in our local news feed about a vet who, among other things, maintained that animals do not feel pain. This idea comes up surprisingly often, what is unusual is that this time it is from…" />
<meta property="og:title" content="Do Animals Feel Pain? | Roger Parkinson" />
<meta property="twitter:card" content="summary_large_image" />
<meta name="twitter:title" property="twitter:title" content="Do Animals Feel Pain?" />
<meta name="twitter:description" property="twitter:description" content="Discusses whether animals feel pain or is that an anthropological illusion." />
The 'description' and the 'og:description' have used the first 160 characters of the text, and only the twitter:description has used the description I added to the page metadata. I tried adding 'og:description' to the page metadata but that made no difference. Is there a way to have them all consistent?
The open graph spec says that keywords should be specified like this:
<meta property="og:tag" content="Books" />
<meta property="og:tag" content="Fantasy" />
<meta property="og:tag" content="Dragons" />
<meta property="og:tag" content="Sheep" />
<meta property="og:tag" content="Cats" />
But the plugin only does this:
<meta name="keywords" content="Books, Fantasy, Dragons, Sheep, Cats" />
Both would be good. I added this code to your php file at the end of onPageInitialized()
$tagArray = explode(',', $meta['keywords']['content']);
foreach ($tagArray as $t) {
$meta['tag'.trim($t)]['property'] = 'og:tag';
$meta['tag'.trim($t)]['content'] = trim($t);
}
//Set new meta to the page
$page->metadata($meta);
It does work but I'm not good at php so there is likely a better way.
I have PR #21 my "dirty" solution for this, if you want to consider. Thanks!
In the plugin's admin tab Twitter Cards
, the Username
placeholder is @
, suggesting to put the username in the format @username
.
However, using this format results in a double @
in the metatag :
<meta name="twitter:site" property="twitter:site" content="@@username" />
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.