Maybe I’m creating too many plugins for my own good right now, but here is another one…
A serp preview field for the panel.
The black thing in the recording is not a bug. It’s a click to get the slug edit modal. It just did not fit in the screen.
What is SEO?
It stands for Search Engine Optimization. Make yourself visible in the search engines.
- Place the
site/fields. The field for the panel.
- Place the
site/plugins. The helper functions for your site.
fields: seo: type: seo
You can add a label on it if you like, but you don’t need to.
Call in template / snippet / pattern
header.php I do like this:
<?php echo $page->seo()->seoTitle('html'); echo $page->seo()->seoDescription('html'); ?>
If you want full control over the HTML, don’t add
html as parameter, like this:
<title><?php echo $page->seo()->seoTitle(); ?></title> <?php if( $page->seo()->hasSeoDescription() ) : ?> <meta name="description" content="<?php echo $page->seo()->seoDescription(); ?>"> <?php endif; ?>
You can append a prefix to the title as well. It’s good for placing the company name last in the title.
c::set('seo.prefix', ' - Some prefix');
- The preview has the look of Google serp.
- The seo title and the meta description will only be cut in the preview, not on the site.
- Newlines are stripped from the textarea and replaced with space.
- If the seo title tag is missing, it will use the
titlefield value instead.
- If the meta description is missing, it will not output anything.
- Title tag is cut, not my character, but by width, just like Google.
- Meta description in the preview is cut after 155 characters.
- You can click on the seo title, meta description and the seo url in the panel to edit them.