A composer package for SEO for all quintype projects
###Important : If any change is made to the package, do the following.
- Create a new release.
- Update the package in Packagist.
- To use the new version of the package in any project, change the version number in composer.json file and run
$ composer update
Note : We are making use of a package called Meta (https://github.com/quintype/meta) forked from https://github.com/RyanNielson/meta for dynamically adding the meta tags into the pages.
Instructions to include the package into a project.
"require": {
...
...
"quintype/seo":"1.0.0",
"quintype/meta":"2.0.0"
},
$ composer install
or
$ composer update
'aliases' => [
...
...
'Meta' => Quintype\Meta\Meta::class,
'Seo' => Quintype\Seo\Seo::class
],
Add an attribute called 'title' in config/quintype.php file as a fall-back value if it is not received from the config API.
return [
...
...
"title" => "Pina Colada"
];
use Meta;
use Seo;
Create a constructor function to initialize the Meta and SEO objects. Do not forget to pass the config(merge local config and config from API response) while initializing the Seo instance.
public function __construct(){
$this->client = new Api(config("quintype.api-host"));
$this->config = array_merge($this->client->config(), config('quintype'));
$this->meta = new Meta();
$this->seo = new Seo($this->config);
}
Prepare the data required for meta tags using these available functions.
$setSeo = $this->seo->FUNCTION_NAME($args);
$this->meta->set($setSeo->prepareTags());
return view('home', $this->toView([
...
...
"meta" => $this->meta
])
);
In the <head> tag of layout.twig file(or the container twig file of the project), call the function to add the meta tags.
{{ meta.display([], true)|raw }}
##AVAILABLE FUNCTIONS
-
home($pageType**)**
-
search($searchKeyword**)**
-
section($pageType, $sectionName, $sectionId**)**
-
staticPage($title**)**
-
story($pageType, $storyArray**)**
-
tag($tagName**)**