1. Go to this page and download the library: Download artesaos/seotools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$seotools = app('seotools');
$metatags = app('seotools.metatags');
$twitter = app('seotools.twitter');
$opengraph = app('seotools.opengraph');
$jsonld = app('seotools.json-ld');
$jsonldMulti = app('seotools.json-ld-multi');
// The behavior is the same as the facade
echo app('seotools')->generate();
namespace App\Http\Controllers;
use Artesaos\SEOTools\Traits\SEOTools as SEOToolsTrait;
class CommonController extends Controller
{
use SEOToolsTrait;
public function index()
{
$this->seo()->setTitle('Home');
$this->seo()->setDescription('This is my page description');
$this->seo()->opengraph()->setUrl('http://current.url.com');
$this->seo()->opengraph()->addProperty('type', 'articles');
$this->seo()->twitter()->setSite('@LuizVinicius73');
$this->seo()->jsonLd()->setType('Article');
$posts = Post::all();
return view('myindex', compact('posts'));
}
}
use Artesaos\SEOTools\Facades\OpenGraph;
OpenGraph::addProperty($key, $value); // value can be string or array
OpenGraph::addImage($url); // add image url
OpenGraph::addImages($url); // add an array of url images
OpenGraph::setTitle($title); // define title
OpenGraph::setDescription($description); // define description
OpenGraph::setUrl($url); // define url
OpenGraph::setSiteName($name); //define site_name
// You can chain methods
OpenGraph::addProperty($key, $value)
->addImage($url)
->addImages($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSiteName($name);
// Generate html tags
OpenGraph::generate();
use Artesaos\SEOTools\Facades\TwitterCard;
TwitterCard::addValue($key, $value); // value can be string or array
TwitterCard::setType($type); // type of twitter card tag
TwitterCard::setTitle($type); // title of twitter card tag
TwitterCard::setSite($type); // site of twitter card tag
TwitterCard::setDescription($type); // description of twitter card tag
TwitterCard::setUrl($type); // url of twitter card tag
TwitterCard::setImage($url); // add image url
// You can chain methods
TwitterCard::addValue($key, $value)
->setType($type)
->setImage($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSite($name);
// Generate html tags
TwitterCard::generate();
use Artesaos\SEOTools\Facades\JsonLd;
JsonLd::addValue($key, $value); // value can be string or array
JsonLd::setType($type); // type of twitter card tag
JsonLd::setTitle($type); // title of twitter card tag
JsonLd::setSite($type); // site of twitter card tag
JsonLd::setDescription($type); // description of twitter card tag
JsonLd::setUrl($type); // url of twitter card tag
JsonLd::setImage($url); // add image url
// You can chain methods
JsonLd::addValue($key, $value)
->setType($type)
->setImage($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSite($name);
// Generate html tags
JsonLd::generate();
use Artesaos\SEOTools\Facades\JsonLdMulti;
JsonLdMulti::newJsonLd(); // create a new JsonLd group
JsonLdMulti::isEmpty(); // check if the current JsonLd group is empty
JsonLdMulti::select($index); // choose the JsonLd group that will be edited by the methods below
JsonLdMulti::addValue($key, $value); // value can be string or array
JsonLdMulti::setType($type); // type of twitter card tag
JsonLdMulti::setTitle($type); // title of twitter card tag
JsonLdMulti::setSite($type); // site of twitter card tag
JsonLdMulti::setDescription($type); // description of twitter card tag
JsonLdMulti::setUrl($type); // url of twitter card tag
JsonLdMulti::setImage($url); // add image url
// You can chain methods
JsonLdMulti::addValue($key, $value)
->setType($type)
->setImage($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSite($name);
// You can add an other group
if(! JsonLdMulti::isEmpty()) {
JsonLdMulti::newJsonLd()
->setType($type)
->setImage($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSite($name);
}
// Generate html tags
JsonLdMulti::generate();
// You will have retrieve <script content="application/ld+json"/>