Looking to hire Laravel developers? Try LaraJobs

laravel-head-markup maintained by m2collective

Description
A package for editing basic website metadata.
Author
Last update
2026/07/27 20:32 (dev-main)
License
Downloads
1

Comments
comments powered by Disqus

Head Markup

A package for editing basic website metadata.

Laravel PHP


Installation

You can install the package via composer:

composer require m2collective/laravel-head-markup

The package will automatically register itself.

Commands

Publishing the configuration file:

php artisan m2collective:head-markup:publish-config

Publishing HTML views:

php artisan m2collective:head-markup:publish-views

Usage

After installing the package, you can edit the basic metadata of your website.

Dependency injection

An example of using a package with the dependency injection:

use M2Collective\HeadMarkup\HeadMarkup;

final class Example 
{
    /**
     * @var HeadMarkup 
     */
    protected HeadMarkup $headMakeup;
    
    /**
     * @param HeadMarkup $headMarkup
     */
    public function __construct(
        HeadMarkup $headMarkup
    ) {
        $this->headMarkup = $headMarkup;
    }
    
    /**
     * @return mixed
     */
    public function head(): mixed {
        $this->headMarkup
            ->setViewport('width=device-width, initial-scale=1')
            ->setCharset('utf-8')
            ->setTitle('Title')
            ->setDescription('Page Description')
            ->setKeywords('Keywords of the page')
            ->setRobots('index, follow')
            ->setAuthor('M2Collective')
            ->setCopyright('M2Collective')
            ->setCanonical(null)
            ->setPrev(null)
            ->setNext(null)
    }
}

Facades

An example of using a package with the facades:

use M2Collective\HeadMarkup\Facades\HeadMarkup;

final class Example 
{
    /**
     * @return mixed
     */
    public function isDevice(): mixed {
        HeadMarkup::setViewport('width=device-width, initial-scale=1')
            ->setCharset('utf-8')
            ->setTitle('Title')
            ->setDescription('Page Description')
            ->setKeywords('Keywords of the page')
            ->setRobots('index, follow')
            ->setAuthor('M2Collective')
            ->setCopyright('M2Collective')
            ->setCanonical(null)
            ->setPrev(null)
            ->setNext(null)
    }
}

Blade

An example of using a package with the blade:

<!DOCTYPE html>
<html lang="en">
    <head>
        <x-head-markup::viewport/>
        <x-head-markup::charset/>
        <x-head-markup::title/>
        <x-head-markup::description/>
        <x-head-markup::keywords/>
        <x-head-markup::robots/>
        <x-head-markup::author/>
        <x-head-markup::copyright/>
        <x-head-markup::canonical/>
        <x-head-markup::prev/>
        <x-head-markup::next/>
    </head>
    <body>
    
    </body>
</html>

License

The MIT License (MIT). Please see the License file for more information.