Laravel Auto Head Tags helps you build the list of head elements for your app

v1.1.6 2022-05-02 13:19 UTC

This package is auto-updated.

Last update: 2022-05-02 13:19:32 UTC


Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads


This package aims to ease the creating of all HTML head tags: meta, links, SEO, Open Graph, Twitter and whatever else you need.

The package will grab all the info it needs from the data sent to Blade:

return view('welcome', [
    'seo' => [
        'title' => 'Your page title',

        'description' => 'The meta description for the page',

        'urls' => [
            'canonical' => ''

    'twitter' => [
        'handle' => '@opticalcortex'

    'image' => [
        'url' => ''

To generate, out of the box, this set of tags for you:

<title>Your page title</title>\n
<meta charset="utf-8" />\n
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />\n
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1" />\n
<meta name="mobile-web-app-capable" content="yes" />\n
<meta name="apple-mobile-web-app-capable" content="yes" />\n
<meta name="apple-mobile-web-app-title" content="Your page title" />\n
<meta name="description" content="The meta description for the page" />\n
<meta name="msapplication-TileColor" content="#ffffff" />\n
<meta name="msapplication-config" content="/favicon/browserconfig.xml" />\n
<meta name="theme-color" content="#ffffff" />\n
<meta itemprop="description" content="The meta description for the page" />\n
<meta property="og:type" content="website" />\n
<meta property="og:title" content="Your page title" />\n
<meta property="og:site_name" content="Laravel" />\n
<meta property="og:description" content="The meta description for the page" />\n
<meta property="og:url" content="" />\n
<meta property="og:image:width" content="1200" />\n
<meta property="og:image:height" content="630" />\n
<meta name="twitter:title" content="Your page title" />\n
<meta name="twitter:site" content="@opticalcortex" />\n
<meta name="twitter:description" content="The meta description for the page" />\n
<meta name="twitter:url" content="" />\n
<meta name="twitter:card" content="summary_large_image" />\n
<meta name="twitter:creator" content="@opticalcortex" />\n
<link rel="manifest" href="/favicon/site.webmanifest" />\n
<link rel="icon" href="/favicon/favicon.ico" />\n
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png" />\n
<link rel="icon" type="image/png" sizes="16x16" />\n
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />\n
<link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#1d1d1d" />\n
<link rel="shortcut icon" href="/favicon/favicon.ico" />\n
<link rel="canonical" href="" />

The list of tags is larger, but if you don't provide enough information to create those tags, they won't be created.


Via Composer

composer require area17/laravel-auto-head-tags

Publish the config file

php artisan vendor:publish --provider="A17\LaravelAutoHeadTags\ServiceProvider"


Add to your blade template

Add the tag @head to your main template:

<!DOCTYPE html>
<html lang="{{ locale() }}">



This directive is also configurable, just publish the configuration and change the blade.directive.


All available tags are on the config file: config/laravel-auto-head-tags.yaml, and everything is configurable. This is an extract of the tags section:

    # META

    # HEAD
    - charset: "{head.charset}|utf-8"
    - name: viewport
      content: "{head.viewport}|width=device-width, initial-scale=1.0, minimum-scale=1"
    - name: author
      content: "{}"
    - http-equiv: "X-UA-Compatible"
      content: "{head.httpEquiv}|IE=Edge"
    - name: mobile-web-app-capable
      content: "{}|yes"
    - name: apple-mobile-web-app-capable
      content: "{}|yes"
    - name: apple-mobile-web-app-title
      content: "{}|{og.title}|{$}"

You can define macros to access Blade data, using {}, and the package can resolve them using the "dot" notation for arrays:

content: "{}"

You can define as many fallbacks you need for those macros:

title: "{title}|{head.title}|{seo.title}|{og.title}|{$}"

And you can also access data from the Laravel config:

content: "{$}"

If it's required to generate more than one URL for a single tag definition, there's loop concept:

- rel: canonical
  href: "{seo.urls.canonical}"
- rel: alternate
  href: "{seo.urls.hreflang:value}"
  hreflang: "{seo.urls.hreflang:key}"

If seo.urls.hreflang is an array made of locales (key) and URLs (value), this configuration will generate these tags:

<link rel="canonical" href="" />
<link rel="alternate" href="" hreflang="fr" />
<link rel="alternate" href="" hreflang="en" />

Change log

Please see CHANGELOG for more information on what has changed recently.


$ composer test


Please see CONTRIBUTING and CODE_OF_CONDUCT for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.