Coder Social home page Coder Social logo

seotools's Introduction

SEOTools - SEO Tools for Laravel and Lumen


SEOTools is a package for Laravel 5.8+ and Lumen that provides helpers for some common SEO techniques.

Current Build Status

Build Status Code Climate

Statistics

Latest Stable Version Total Downloads Latest Unstable Version License

For license information check the LICENSE-file.

Features

Installation

1 - Dependency

The first step is using composer to install the package and automatically update your composer.json file, you can do this by running:

composer require artesaos/seotools

Note: If you are using Laravel 5.5, the steps 2 and 3, for providers and aliases, are unnecessaries. SEOTools supports Laravel new Package Discovery.

2 - Provider

You need to update your application configuration in order to register the package so it can be loaded by Laravel, just update your config/app.php file adding the following code at the end of your 'providers' section:

config/app.php

<?php

return [
    // ...
    'providers' => [
        Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class,
        // ...
    ],
    // ...
];

Lumen

Go to /bootstrap/app.php file and add this line:

<?php
// ...

$app = new Laravel\Lumen\Application(
    dirname(__DIR__)
);

// ...

$app->register(Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class);

// ...

return $app;

3 - Facades

Note: facades are not supported in Lumen.

You may get access to the SEO tool services using following facades:

  • Artesaos\SEOTools\Facades\SEOMeta
  • Artesaos\SEOTools\Facades\OpenGraph
  • Artesaos\SEOTools\Facades\TwitterCard
  • Artesaos\SEOTools\Facades\JsonLd
  • Artesaos\SEOTools\Facades\JsonLdMulti
  • Artesaos\SEOTools\Facades\SEOTools

You can setup a short-version aliases for these facades in your config/app.php file. For example:

<?php

return [
    // ...
    'aliases' => [
        'SEOMeta'       => Artesaos\SEOTools\Facades\SEOMeta::class,
        'OpenGraph'     => Artesaos\SEOTools\Facades\OpenGraph::class,
        'Twitter'       => Artesaos\SEOTools\Facades\TwitterCard::class,
        'JsonLd'        => Artesaos\SEOTools\Facades\JsonLd::class,
        'JsonLdMulti'   => Artesaos\SEOTools\Facades\JsonLdMulti::class,
        // or
        'SEO' => Artesaos\SEOTools\Facades\SEOTools::class,
        // ...
    ],
    // ...
];

4 Configuration

Publish config

In your terminal type

php artisan vendor:publish

or

php artisan vendor:publish --provider="Artesaos\SEOTools\Providers\SEOToolsServiceProvider"

Lumen does not support this command, for it you should copy the file src/resources/config/seotools.php to config/seotools.php of your project

In seotools.php configuration file you can determine the properties of the default values and some behaviors.

seotools.php

  • meta
    • defaults - What values are displayed if not specified any value for the page display. If the value is false, nothing is displayed.
    • webmaster - Are the settings of tags values for major webmaster tools. If you are null nothing is displayed.
  • opengraph
    • defaults - Are the properties that will always be displayed and when no other value is set instead. You can add additional tags that are not included in the original configuration file.
  • twitter
    • defaults - Are the properties that will always be displayed and when no other value is set instead. You can add additional tags that are not included in the original configuration file.
  • json-ld
    • defaults - Are the properties that will always be displayed and when no other value is set instead. You can add additional tags that are not included in the original configuration file.

Usage

Lumen Usage

Note: facades are not supported in Lumen.

<?php

$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();

Meta tags Generator

With SEOMeta you can create meta tags to the head

Opengraph tags Generator

With OpenGraph you can create OpenGraph tags to the head

Twitter for Twitter Cards tags Generator

With Twitter you can create OpenGraph tags to the head

In your controller

<?php

namespace App\Http\Controllers;

use Artesaos\SEOTools\Facades\SEOMeta;
use Artesaos\SEOTools\Facades\OpenGraph;
use Artesaos\SEOTools\Facades\TwitterCard;
use Artesaos\SEOTools\Facades\JsonLd;
// OR with multi
use Artesaos\SEOTools\Facades\JsonLdMulti;

// OR
use Artesaos\SEOTools\Facades\SEOTools;

class CommonController extends Controller
{
    public function index()
    {
        SEOMeta::setTitle('Home');
        SEOMeta::setDescription('This is my page description');
        SEOMeta::setCanonical('https://codecasts.com.br/lesson');

        OpenGraph::setDescription('This is my page description');
        OpenGraph::setTitle('Home');
        OpenGraph::setUrl('http://current.url.com');
        OpenGraph::addProperty('type', 'articles');

        TwitterCard::setTitle('Homepage');
        TwitterCard::setSite('@LuizVinicius73');

        JsonLd::setTitle('Homepage');
        JsonLd::setDescription('This is my page description');
        JsonLd::addImage('https://codecasts.com.br/img/logo.jpg');

        // OR

        SEOTools::setTitle('Home');
        SEOTools::setDescription('This is my page description');
        SEOTools::opengraph()->setUrl('http://current.url.com');
        SEOTools::setCanonical('https://codecasts.com.br/lesson');
        SEOTools::opengraph()->addProperty('type', 'articles');
        SEOTools::twitter()->setSite('@LuizVinicius73');
        SEOTools::jsonLd()->addImage('https://codecasts.com.br/img/logo.jpg');

        $posts = Post::all();

        return view('myindex', compact('posts'));
    }

    public function show($id)
    {
        $post = Post::find($id);

        SEOMeta::setTitle($post->title);
        SEOMeta::setDescription($post->resume);
        SEOMeta::addMeta('article:published_time', $post->published_date->toW3CString(), 'property');
        SEOMeta::addMeta('article:section', $post->category, 'property');
        SEOMeta::addKeyword(['key1', 'key2', 'key3']);

        OpenGraph::setDescription($post->resume);
        OpenGraph::setTitle($post->title);
        OpenGraph::setUrl('http://current.url.com');
        OpenGraph::addProperty('type', 'article');
        OpenGraph::addProperty('locale', 'pt-br');
        OpenGraph::addProperty('locale:alternate', ['pt-pt', 'en-us']);

        OpenGraph::addImage($post->cover->url);
        OpenGraph::addImage($post->images->list('url'));
        OpenGraph::addImage(['url' => 'http://image.url.com/cover.jpg', 'size' => 300]);
        OpenGraph::addImage('http://image.url.com/cover.jpg', ['height' => 300, 'width' => 300]);

        JsonLd::setTitle($post->title);
        JsonLd::setDescription($post->resume);
        JsonLd::setType('Article');
        JsonLd::addImage($post->images->list('url'));

        // OR with multi

        JsonLdMulti::setTitle($post->title);
        JsonLdMulti::setDescription($post->resume);
        JsonLdMulti::setType('Article');
        JsonLdMulti::addImage($post->images->list('url'));
        if(! JsonLdMulti::isEmpty()) {
            JsonLdMulti::newJsonLd();
            JsonLdMulti::setType('WebPage');
            JsonLdMulti::setTitle('Page Article - '.$post->title);
        }

        // Namespace URI: http://ogp.me/ns/article#
        // article
        OpenGraph::setTitle('Article')
            ->setDescription('Some Article')
            ->setType('article')
            ->setArticle([
                'published_time' => 'datetime',
                'modified_time' => 'datetime',
                'expiration_time' => 'datetime',
                'author' => 'profile / array',
                'section' => 'string',
                'tag' => 'string / array'
            ]);

        // Namespace URI: http://ogp.me/ns/book#
        // book
        OpenGraph::setTitle('Book')
            ->setDescription('Some Book')
            ->setType('book')
            ->setBook([
                'author' => 'profile / array',
                'isbn' => 'string',
                'release_date' => 'datetime',
                'tag' => 'string / array'
            ]);

        // Namespace URI: http://ogp.me/ns/profile#
        // profile
        OpenGraph::setTitle('Profile')
             ->setDescription('Some Person')
            ->setType('profile')
            ->setProfile([
                'first_name' => 'string',
                'last_name' => 'string',
                'username' => 'string',
                'gender' => 'enum(male, female)'
            ]);

        // Namespace URI: http://ogp.me/ns/music#
        // music.song
        OpenGraph::setType('music.song')
            ->setMusicSong([
                'duration' => 'integer',
                'album' => 'array',
                'album:disc' => 'integer',
                'album:track' => 'integer',
                'musician' => 'array'
            ]);

        // music.album
        OpenGraph::setType('music.album')
            ->setMusicAlbum([
                'song' => 'music.song',
                'song:disc' => 'integer',
                'song:track' => 'integer',
                'musician' => 'profile',
                'release_date' => 'datetime'
            ]);

         //music.playlist
        OpenGraph::setType('music.playlist')
            ->setMusicPlaylist([
                'song' => 'music.song',
                'song:disc' => 'integer',
                'song:track' => 'integer',
                'creator' => 'profile'
            ]);

        // music.radio_station
        OpenGraph::setType('music.radio_station')
            ->setMusicRadioStation([
                'creator' => 'profile'
            ]);

        // Namespace URI: http://ogp.me/ns/video#
        // video.movie
        OpenGraph::setType('video.movie')
            ->setVideoMovie([
                'actor' => 'profile / array',
                'actor:role' => 'string',
                'director' => 'profile /array',
                'writer' => 'profile / array',
                'duration' => 'integer',
                'release_date' => 'datetime',
                'tag' => 'string / array'
            ]);

        // video.episode
        OpenGraph::setType('video.episode')
            ->setVideoEpisode([
                'actor' => 'profile / array',
                'actor:role' => 'string',
                'director' => 'profile /array',
                'writer' => 'profile / array',
                'duration' => 'integer',
                'release_date' => 'datetime',
                'tag' => 'string / array',
                'series' => 'video.tv_show'
            ]);

        // video.tv_show
        OpenGraph::setType('video.tv_show')
            ->setVideoTVShow([
                'actor' => 'profile / array',
                'actor:role' => 'string',
                'director' => 'profile /array',
                'writer' => 'profile / array',
                'duration' => 'integer',
                'release_date' => 'datetime',
                'tag' => 'string / array'
            ]);

        // video.other
        OpenGraph::setType('video.other')
            ->setVideoOther([
                'actor' => 'profile / array',
                'actor:role' => 'string',
                'director' => 'profile /array',
                'writer' => 'profile / array',
                'duration' => 'integer',
                'release_date' => 'datetime',
                'tag' => 'string / array'
            ]);

        // og:video
        OpenGraph::addVideo('http://example.com/movie.swf', [
                'secure_url' => 'https://example.com/movie.swf',
                'type' => 'application/x-shockwave-flash',
                'width' => 400,
                'height' => 300
            ]);

        // og:audio
        OpenGraph::addAudio('http://example.com/sound.mp3', [
                'secure_url' => 'https://secure.example.com/sound.mp3',
                'type' => 'audio/mpeg'
            ]);

        // og:place
        OpenGraph::setTitle('Place')
             ->setDescription('Some Place')
            ->setType('place')
            ->setPlace([
                'location:latitude' => 'float',
                'location:longitude' => 'float',
            ]);

        return view('myshow', compact('post'));
    }
}

SEOTrait

<?php

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'));
    }
}

In Your View

Pro Tip: Pass the parameter true to get minified code and reduce filesize.

<html>
<head>
    {!! SEOMeta::generate() !!}
    {!! OpenGraph::generate() !!}
    {!! Twitter::generate() !!}
    {!! JsonLd::generate() !!}
    // OR with multi
    {!! JsonLdMulti::generate() !!}

    <!-- OR -->
    {!! SEO::generate() !!}

    <!-- MINIFIED -->
    {!! SEO::generate(true) !!}

    <!-- LUMEN -->
    {!! app('seotools')->generate() !!}
</head>
<body>

</body>
</html>
<html>
<head>
    <title>Title - Over 9000 Thousand!</title>
    <meta name='description' itemprop='description' content='description...'>
    <meta name='keywords' content='key1, key2, key3'>
    <meta property='article:published_time' content='2015-01-31T20:30:11-02:00'>
    <meta property='article:section' content='news'>

    <meta property="og:description" content="description...">
    <meta property="og:title" content="Title">
    <meta property="og:url" content="http://current.url.com">
    <meta property="og:type" content="article">
    <meta property="og:locale" content="pt-br">
    <meta property="og:locale:alternate" content="pt-pt">
    <meta property="og:locale:alternate" content="en-us">
    <meta property="og:site_name" content="name">
    <meta property="og:image" content="http://image.url.com/cover.jpg">
    <meta property="og:image" content="http://image.url.com/img1.jpg">
    <meta property="og:image" content="http://image.url.com/img2.jpg">
    <meta property="og:image" content="http://image.url.com/img3.jpg">
    <meta property="og:image:url" content="http://image.url.com/cover.jpg">
    <meta property="og:image:size" content="300">

    <meta name="twitter:card"content="summary">
    <meta name="twitter:title"content="Title">
    <meta name="twitter:site"content="@LuizVinicius73">

    <script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","name":"Title - Over 9000 Thousand!"}</script>
    <!-- OR with multi -->
    <script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","name":"Title - Over 9000 Thousand!"}</script>
    <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Title - Over 9000 Thousand!"}</script>
</head>
<body>

</body>
</html>

Using Macro

Using the same code in multiple places can be tedious, which is why this package includes a Macroable trait. This trait allows additional functionality to be added to a class that was not defined in the class definition, using a simple trait.

For example, imagine that you need to add meta titles and descriptions for your pages. You can add your Macroable functions in the AppServiceProvider or create a dedicated file for this purpose, and define your function as shown in the code snippet:

    SEOTools::macro('webPage', function (string $title, string $description) {
        SEOMeta::setTitle($title);
        SEOMeta::setDescription($description);
        SEOMeta::setCanonical('http://current.url.com');
        OpenGraph::setDescription($description);
        OpenGraph::setTitle($title);
        OpenGraph::setUrl('http://current.url.com');
        OpenGraph::addProperty('type', 'webpage');
    });

In your controller, you can use the following code to utilize the function:

    SEOTools::webPage('Page title', 'Page description');

API (SEOMeta)

<?php

use Artesaos\SEOTools\Facades\SEOMeta;

SEOMeta::addKeyword($keyword);
SEOMeta::addMeta($meta, $value = null, $name = 'name');
SEOMeta::addAlternateLanguage($lang, $url);
SEOMeta::addAlternateLanguages(array $languages);
SEOMeta::setTitleSeparator($separator);
SEOMeta::setTitle($title);
SEOMeta::setTitleDefault($default);
SEOMeta::setDescription($description);
SEOMeta::setKeywords($keywords);
SEOMeta::setRobots($robots);
SEOMeta::setCanonical($url);
SEOMeta::setPrev($url);
SEOMeta::setNext($url);
SEOMeta::removeMeta($key);

// You can chain methods
SEOMeta::setTitle($title)
            ->setDescription($description)
            ->setKeywords($keywords)
            ->addKeyword($keyword)
            ->addMeta($meta, $value);

// Retrieving data
SEOMeta::getTitle();
SEOMeta::getTitleSession();
SEOMeta::getTitleSeparator();
SEOMeta::getKeywords();
SEOMeta::getDescription();
SEOMeta::getCanonical($url);
SEOMeta::getPrev($url);
SEOMeta::getNext($url);
SEOMeta::getRobots();
SEOMeta::reset();

SEOMeta::generate();

API (OpenGraph)

<?php

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();

API (TwitterCard)

<?php

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();

API (JsonLd)

<?php

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();

API (JsonLdMulti)

<?php

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"/>

API (SEO)

Facilitates access to all the SEO Providers

<?php

use Artesaos\SEOTools\Facades\SEOTools;

SEOTools::metatags();
SEOTools::twitter();
SEOTools::opengraph();
SEOTools::jsonLd();

SEOTools::setTitle($title);
SEOTools::getTitle($session = false);
SEOTools::setDescription($description);
SEOTools::setCanonical($url);
SEOTools::addImages($urls);

Missing Features

There are many SEO-related features, which you may need for your project. While this package provides support for the basic ones, other are out of its scope. You'll have to use separate packages for their integration.

SiteMap

This package does not support sitemap files generation. Please consider usage one of the following packages for it:

URL Trailing Slash

This package does not handle URL consistency regardless absence or presence of the slash symbol at its end. Please consider usage one of the following packages if you need it:

Microdata Markup

This package does provide generation of the microdata HTML markup. If you need to create HTML like the following one:

<div itemscope>
 <p>My name is
  <span itemprop="name">Elizabeth</span>.</p>
</div>

you will need to handle it yourself.

Note: nowadays microdata markup is considered to be outdated. It is recommened to use JSON Linked Data instead, which is supported by this extension.

RSS

This package does not support RSS feed generation or related meta data composition. Please consider usage one of the following packages for it:

seotools's People

Contributors

biptaste avatar brentmullen avatar carusogabriel avatar da-sie avatar edbizarro avatar emtudo avatar fuhrmann avatar georgeboot avatar glennbergmans avatar j-brk avatar klimov-paul avatar mauri870 avatar mcnub avatar nishalgurung4 avatar nunomaduro avatar omarherri avatar peterangelov avatar poldixd avatar rajakhoury avatar rammazzoti2000 avatar ramon-villain avatar robovarga avatar scrutinizer-auto-fixer avatar shubhang-arora avatar thehelvetian avatar toshieuya avatar vinicius73 avatar vluzrmos avatar yepzy avatar yukato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seotools's Issues

Application name in every title

On local server if there is no title set through this package, title is created with the default name from config file, however on live server the default title is ignored.

Also on localhost every title set through the package has the default name included after the main title separated with the separator, but on live server this is also ignored.

Homepage meta title

Usually meta titles are like Page Title - App Name which is odd for homepage.
I would like to set App Name - Page Title for home page. Is there a way to achieve this?

Would be helpful if there was a homepage option in config file.

Regards

SetTitle always append defaults

Hi and thanks for the great work.
I don't know why but whenever i set new title in my controller, for example with SEO::setTitle('test'); or SEO::setTitle('test',false); the defaults value of title on seotools.php is appendend. That means the final title of the page will be 'test+defaults_title'. How can i override the value on seotools.php or disable the append of the default title?

here is the seotools.php
`<?php

return [
'meta' => [
/*
* The default configurations to be used by the meta generator.
*/

    /*
     * EXCLUDE SEO ROUTES PANEL
    */
    /*
     * More about
     *    - titles at: https://moz.com/learn/seo/title-tag
     *    - description: https://moz.com/learn/seo/meta-description
     *    - canonical url: https://moz.com/blog/canonical-url-tag-the-most-important-advancement-in-seo-practices-since-sitemaps
     */
    'defaults'       => [
        'title'        => "myDefaultString", // set false to total remove
        'description'  => "MyDefaultDescription.", // set false to total remove
        'separator'    => false,
        'keywords'     => [ 'test'],
        'canonical'    => false, // Set null for using Url::current(), set false to total remove
                                 //multiple pages considered as one
    ],

    /*
     * Webmaster tags are always added.
     */
    'webmaster_tags' => [
        'google'    => null,
        'bing'      => null,
        'alexa'     => null,
        'pinterest' => null,
        'yandex'    => null,
    ],
],
'opengraph' => [
    /*
     * The default configurations to be used by the opengraph generator.
     */
   
    'defaults' => [
        'title'        => "myDefaultString", // set false to total remove
        'description'  => "MyDefaultDescription.", // set false to total remove // set false to total remove
        'url'         => false, // Set null for using Url::current(), set false to total remove
        'type'        => false,
        'site_name'   => false,
        'images'      => [],
    ],
],
'twitter' => [
    /*
     * The default values to be used by the twitter cards generator.
     */
    'defaults' => [
      //'card'        => 'summary',
      //'site'        => '@LuizVinicius73',
    ],
],

];
`

function to set default seperator

This will make it easy to change to this format for page title tags:

page name | site

Function is simple setter.

    public function setSeperator($sep) {
        $this->titleSeperator = $sep;
    }

Override title concatenation

The title separator and default page title is always concatenated to the title, even if it's specified. This behaviour is really cool but sometimes it's useful to just omit that concatenation. Is it currently possible?

setKeywords returns error: undefined method

Hi ! , first thank you so much for this amazing work,
I ran into an issue , I tried to set the keywords in my controller like this:

// before class
use SEO;

---
// in controller:
SEO::setKeywords('key1', 'key2', 'key3');

but I ran into this error:

Call to undefined method Artesaos\SEOTools\SEOTools::setKeywords()

I tried this code too:

//before class
use Artesaos\SEOTools\Traits\SEOTools as SEOToolsTrait;

---
//after class
use SEOToolsTrait;

---
// in controller:
$this->seo()->setKeywords(['key1', 'key2', 'key3']);

with the same error, Note, those are working fine with no problems:

SEO::setTitle('title');
SEO::setDescription(str_limit($work->description, $limit = 120, $end = '...'));
SEO::opengraph()->addProperty('type', 'articles');

Default configuration obsolete

The defaults config file that gets published is barely used, and when it is, it is very inconsistent. I think we should either get rid of it entirely and rely on built-in defaults on the parameters, or rely more heavily on it in a much more consistent manner. What do you think?

Add Use SEOMeta;

Missing from documentation:

Add "Use SEOMeta;" to controllers to access the Alias.

Twitter image

Twitter::addImage('example.jpeg');

produces this code:

Why is the 0 after images? And by the Twitter, this meta tag must be twitter:image

Make a release?

It's not installing via composer maybe it requires a 1.0 release?

Error in view

Error: htmlentities() expects parameter 1 to be string, object given (View:

I wnat to chage title from pages
`@extends('layouts.app')
@section('content')
{{ SEO::setTitle('test') }}

bla bla bla
@endsection`

in layouts.app i generate SEO

Multi meta tags same name?

I want to add multiple tags article:tag but apparently you just allow a meta tag is displayed

examples:
SEO::opengraph()->addProperty('video:tag', 'Tag 1');
SEO::opengraph()->addProperty('video:tag', 'Tag 2');

but it only shows

< meta property="og:video:tag" content="Tag 2">

<link rel="amphtml">

Hi there - Is there a way to add an amphtml link in addition to the current canonical link?

<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">

Not sure if I am missing something, or if this is a new feature request.

fb:app_id support

I want to add my facebook app_id and its should look like this

with seotools i can only add it like this

article tags (array) generated as og:tag instead article:tag

hi, i just try this seo tools and i got this issue when i trying to generate article tag

this is in my controller:

OpenGraph::setArticle([
                'published_time' => $par->post_time,
                'author' => $par->author->user_fullname,
                'section' => $category,
                'tag' => $tags
            ]);

when the $tags is string, it generated as:
<meta property="article:tag" content="tag" />

but when it's an array, it generated as:
<meta property="og:tag" content="tag" />

{{SEOMeta::generate()}}

Laravel 5 requires further escaping like so: {!! SEOMeta::generate() !!}

This is the output from {{SEOMeta::generate()}}

image

Itemprop

Hi,

is it possible to implement the itemprop meta? Like:

SEOitemProp::name('Hello world!');
SEOitemProp::description('A new description');

and so on?

Use double quotes for description meta

Use double quotes for description meta so apostrophe's don't break.

image

Change in SEOMeta.php line 85

$html[] = "<meta name=\"description\" itemprop=\"description\" content=\"{$description}\" />";

Override Open Graph Default Image

First thanks for your hard work on this! Is it possible to override the default open graph image? With twitter we can set the card image with setImage() in the controller but with open graph we can only use addImage() which does not override the default open graph image. Facebook is pulling the first it sees, which is the default.

No version specified

Hi and thanks for the great work.

While reading the documentation, i could not identify which versions of laravel the project is compactible with.

Could you please add that!

Thanks and once more, great work.

Default Title

How to set default title to two areas, example:

Admin in admin section and Name of Site in front?

Set robots meta

Hello,
Although we can use robots.txt, robots meta is still useful in some cases, for example, on user/category posts listing page we may need noindex, follow.

Could you pls bring robots meta tag feature in your package?

Regards
almamun

OpenGraph - tags não usadas

Reparei que existe um array de config no método generate que configura quais tags serão geradas, por default somente image, video e audio estão habilitados, porém não existe uma forma de ativar as outras tags.

$props = [
 'images'                      => ['image',   true],
 'articleProperties'           => ['article', false],
 'profileProperties'           => ['profile', false],
 'bookProperties'              => ['book',    false],
 'musicSongProperties'         => ['music',   false],
 'musicAlbumProperties'        => ['music',   false],
 'musicPlaylistProperties'     => ['music',   false],
 'musicRadioStationProperties' => ['music',   false],
 'videoMovieProperties'        => ['video',   false],
 'videoEpisodeProperties'      => ['video',   false],
 'videoTVShowProperties'       => ['video',   false],
 'videoOtherProperties'        => ['video',   false],
 'videoProperties'             => ['video',   true],
 'audioProperties'             => ['audio',   true],
];

Mesmo colocando true em todas os itens do array não afeta em nada na geração, e alguns métodos continuam não tendo nenhum efeito na geração das tags, exemplo setProfile, setArticle, setBook e etc

lowercase canonical tag

Hi there,

I was wondering it there is any way to enforce canonical tag to be lowercase?

Regards,
Mehdi

OpenGraph

Hi,

why don't put in defaults value url Url::current() like the canonical one?

Agnostic Package

Transforming the package in a package that does not depend on Laravel.


Transformar o pacote em um pacote que não dependa do Laravel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.