Allows management of page title, meta description and meta keywords.
"require" : {
// ...
"astina/seo-bundle":"dev-master",
}
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Astina\Bundle\SeoBundle\AstinaSeoBundle(),
);
}
Add routing if you want to be able to edit page meta data directly.
astina_seo:
resource: "@AstinaSeoBundle/Resources/config/routing.yml"
Warning: make sure to protect this URL in your app/config/security.yml
Place {{ seo_meta_tags(app.request) }} in your Twig template where you want the meta tags to be rendered.
Parameters:
/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @param string $defaultTitle
* @param array $defaults
* @param string $titleSuffix
* @return string
*/
public function renderPageMetaTags(Request $request, $defaultTitle = null, array $defaults = array(), $titleSuffix = null)
The function tries to find a PageMetaData entity for the current request and uses it to render the meta tags.
Configure global default values for title, description and keywords if needed:
# app/config.yml
astina_seo:
global_defaults:
title: "Foo App"
description: "The greatest and bestest app in the internet"
keywords: "greatest, bestest"
@todo: UI to create/delete PageMetaData entitites.
How can I help you explore Laravel packages today?