PHPackages                             graystevens/laravel-head - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. graystevens/laravel-head

AbandonedArchivedLibrary[Templating &amp; Views](/categories/templating)

graystevens/laravel-head
========================

Customize and automate head section of your layouts for Laravel

1.0(11y ago)4156MITPHPPHP &gt;=5.3.0

Since Feb 17Pushed 11y ago1 watchersCompare

[ Source](https://github.com/graystevens/laravel-head)[ Packagist](https://packagist.org/packages/graystevens/laravel-head)[ RSS](/packages/graystevens-laravel-head/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

laravel-head (for Laravel 5)
============================

[](#laravel-head-for-laravel-5)

This package automate and facilitate management of the `` section for your HTML5 layouts with Laravel. It provides utilities for:

- Meta tags.
- Link tags.
- Stylesheets.
- Scripts.
- Charset, favicon, title and description tags.
- Search engines.
- Responsive design.
- Internet Explorer compatibility.
- Facebook's Open Graph protocol.
- Twitter Card.
- Google's Universal Analytics.

Installation
------------

[](#installation)

Require this package in your composer.json and run composer update:

```
"graystevens/laravel-head": "dev-master"

```

After updating composer, add the ServiceProvider to the providers array in app/config/app.php:

```
'graystevens\LaravelHead\LaravelHeadServiceProvider',

```

And also add the `Head` facade to the same file, like so:

```
'Head' => 'graystevens\LaravelHead\LaravelHeadFacade',

```

You need to publish the config of this package:

```
$ php artisan vendor:publish

```

Usage
-----

[](#usage)

You can see a summary of all available methods in the [cheatsheet](https://github.com/graystevens/laravel-head/blob/master/CHEATSHEET.md).

#### Rendering

[](#rendering)

To display all custom tags in the `` section, simply add in your layout:

```

// or with a blade layout

	{!! Head::render() !!}

```

#### Basic settings

[](#basic-settings)

In package's config.php, you can set some default values like charset, sitename, description, favicon... (see comments in config.php for more explanations). These settings will be used if you don't override them for current requests with special methods (in your Routes or Controllers):

```
// define encoding for  tag
Head::setCharset('charset');

// define a title for  tag
Head::setTitle('title');

// de|activate the addition of default sitename to title
Head::noSitename();
Head::doSitename();

// define description for  tag
Head::setDescription('description');

// define a favicon for  tags (relative to public path, without extension)
Head::setFavicon('favicon');

```

You can also remove a tag by filling it with blank, for example:

```
Head::setFavicon('');

```

#### Special utilities

[](#special-utilities)

###### Search engines

[](#search-engines)

By default, the `Head::render()` method will prevent your site from being crawled and indexed when not in production mode, by adding in your `` section:

```

```

###### Internet Explorer compatibilty

[](#internet-explorer-compatibilty)

The `Head::render()` method can also automatically renders two commonly used tags for forcing IE compatibility. Set default values (boolean) in config.php for `'ie_edge' => true|false,` and `'html5_shiv' => true|false,` to display:

```
// ie_edge is true

// html5_shiv is true

```

You can also override default settings for current requests with:

```
// de|activate ie_edge
Head::noIeEdge();
Head::doIeEdge();

// de|activate html5_shiv
Head::noShiv();
Head::doShiv();

```

###### Responsive design

[](#responsive-design)

A commonly used tag for responsive design can automatically be displayed if set to true in config.php (`'responsive' => true|false,`). It will render:

```
// responsive set to true

```

You can override default setting for current requests with:

```
// de|activate responsive
Head::noResponsive();
Head::doResponsive();

```

#### Meta tags

[](#meta-tags)

###### Basic usage

[](#basic-usage)

You can set as many meta tags as you need in your Routes or Controllers:

```
Head::addMeta(array('type' => array('value' => 'content')));

```

For example

```
Head::addMeta(array(
	'name' => array(
		'copyright' => 'My Company',
		'author' => 'Me',
	),
	'http-equiv' => array(
		'pragma' => 'no-cache',
	),
	'property' => array(
		'og:title' => 'Title for Open Graph',
	),
));

```

will render:

```

```

If you need to add only one meta tag, you can also use:

```
Head::addOneMeta('type', 'value', 'content');

```

###### Open Graph

[](#open-graph)

The `Head::render()` method can automatically display a bunch of meta tags for Facebook's Open Graph protocol if you activate it in config.php. You can also set some default values. No tag will be displayed if a value is not defined or if a file does not exist.

```
// rendered HTML in  section if facebook's active is set to true in config.php

```

You can de|activate Open Graph for current requests with:

```
Head::noFacebook();
Head::doFacebook();

```

Deactivation will also remove Open Graph's tags that you manually defined with the `Head::addMeta()` and `Head::addOneMeta()` methods.

###### Twitter Card

[](#twitter-card)

The `Head::render()` method can automatically display a bunch of meta tags for Twitter Card if you activate it in config.php. You can also set some default values. No tag will be displayed if a value is not defined or if a file does not exist.

```
// rendered HTML in  section if twitter's active is set to true in config.php

```

You can de|activate Twitter Card for current requests with:

```
Head::noTwitter();
Head::doTwitter();

```

Deactivation will also remove Twitter Card's tags that you manually defined with the `Head::addMeta()` and `Head::addOneMeta()` methods.

#### Link tags

[](#link-tags)

You can set as many link tags as you need in your Routes or Controllers:

```
Head::addLink(array(array('rel', 'href', 'type', array('attr' => 'value'), 'condition')));

```

Type, Attributes and Condition are optionals. Condition stands for conditional comments (see [Stylesheets](https://github.com/gwnobots/laravel-head#stylesheets) for more explanations).

For example

```
Head::addLink(array(
	array('canonical', 'http://domain.com/whatyouwant'),
	array('alternate', 'http://url-to-your-feed', 'application/rss+xml', array('title' => 'RSS')),
));

```

will render:

```

```

If you need to add only one link tag, you can also use:

```
Head::addOneLink('rel', 'href', 'type', array('attr' => 'value'), 'condition');

```

You cannot override a link tag contrary to meta tags.

#### Stylesheets

[](#stylesheets)

###### Basic usage

[](#basic-usage-1)

You can set as many stylesheets as you need in your Routes or Controllers:

```
Head::addCss(array('file' => 'media'));

```

By default, if you let it blank, media is set to 'all'. If you need conditional comment, you can also use:

```
Head::addCss(array('file' => array('media', 'condition')));

```

For example

```
Head::addCss(array(
	'firstfile' => 'screen and (min-width:480px)',
	'secondfile' => array('', 'lt IE 9'),
));

```

will render

```

```

You can also add only one stylesheet:

```
Head::addOneCss('file', 'media', 'condition');

```

where media and condition are optional. If file does not exist, the tag will not be displayed.

###### Settings and external resources

[](#settings-and-external-resources)

In config.php, you can define a default path for .css files (assets -&gt; paths -&gt; css), relative to public path. So when adding a stylesheet you should use the file's path and name (without extension) from this default one.

You can also load external resources defined in config.php (assets -&gt; cdn). You must use the same name for cdn's in config.php and when adding a stylesheet.

You cannot override a stylesheet: stylesheets are rendered only if they have not already been added, so be careful with dependencies.

#### Scripts

[](#scripts)

Scripts are managed the same way as stylesheets:

```
Head::addScript(array('file' => 'load'));
Head::addScript(array('file' => array('load', 'condition')));
Head::addOneScript('file', 'load', 'condition');

```

Load only accept blank, 'defer' or 'async' as values. Load and condition are optional. You can also set path and cdn's in config.php.

#### Google's Universal Analytics

[](#googles-universal-analytics)

You can automatically add new Google's Universal Analytics at the end of the `` section by setting analytics' active to true in config.php. Don't forget to add your Product ID. The script will not be displayed if not in production mode. By default, Universal Analytics script load asynchronously.

You can also override the script by filling analytics' script in config.php, for example if you use custom methods, or another service provider: paste the complete script, without the `` tags.

You can de|activate the script for current requests with:

```
Head:noAnalytics();
Head:doAnalytics();

```

#### Miscellaneous

[](#miscellaneous)

You can add any additional tags, or custom code like comments, at the end of the `` section with:

```
// several additions
Head::addMisc(array('First additional code', 'Second additional code', ...));
// or only one addition
Head::addMisc('My additional code');

```

Cheat Sheet
-----------

[](#cheat-sheet)

Go to a summary of all [available methods](https://github.com/graystevens/laravel-head/blob/master/CHEATSHEET.md).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c90f6bf21db9ad2678e7097f7e65c9642731af4fa3dac315717cceb501ceba02?d=identicon)[graystevens](/maintainers/graystevens)

---

Top Contributors

[![graystevens](https://avatars.githubusercontent.com/u/331262?v=4)](https://github.com/graystevens "graystevens (7 commits)")[![blackfyre](https://avatars.githubusercontent.com/u/1991410?v=4)](https://github.com/blackfyre "blackfyre (1 commits)")[![mbardelmeijer](https://avatars.githubusercontent.com/u/1583095?v=4)](https://github.com/mbardelmeijer "mbardelmeijer (1 commits)")

---

Tags

laravelfacebookHTML5twitterlayoutanalyticsmetascriptsstylesheets

### Embed Badge

![Health badge](/badges/graystevens-laravel-head/health.svg)

```
[![Health](https://phpackages.com/badges/graystevens-laravel-head/health.svg)](https://phpackages.com/packages/graystevens-laravel-head)
```

###  Alternatives

[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[stijnvanouplines/blade-country-flags

A package to easily make use of country flags in your Laravel Blade views.

26307.2k6](/packages/stijnvanouplines-blade-country-flags)[cornford/bootstrapper

An easy way to intergrate Twitter Bootstrap with Laravel.

252.7k](/packages/cornford-bootstrapper)[ycs77/inertia-laravel-ssr-head

Simple SSR Head for Inertia Laravel

3211.5k](/packages/ycs77-inertia-laravel-ssr-head)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
