There are currently two kinds of values we need to deal with regarding SEO:
Title
Used in the title tag and in some meta tags, can be set by a view, by a model or have a default value.
Other meta values
Other meta and open graph tags.
Proposal
A "meta" object to deal with these values.
The default values would be set in the layout file via an array, or via a view composer. Child views could pass values to merge with the original meta array.
{{-- layout.blade.php --}}
<html>
<head>
{{-- Full example... --}}
@php(meta()->push($meta ?? []))
<title>{{ meta()->title() }}</title>
{{ meta()->tags() }}
{{-- ...which could be distilled to something leaner like this... --}}
{{ meta()->with($meta ?? []) }}
</head>
<body>
</body>
</html>
We can also add some fun things like easier title handling.
// A default title when none is provided
meta()->defaultTitle('Spatie');
// If a custom title is provided, transform it
meta()->transformTitle(function (string $title): string {
return "{$title} — Spatie webdesign Antwerpen";
});
There are currently two kinds of values we need to deal with regarding SEO:
Title Used in the
title
tag and in some meta tags, can be set by a view, by a model or have a default value.Other meta values Other meta and open graph tags.
Proposal
A "meta" object to deal with these values.
The default values would be set in the layout file via an array, or via a view composer. Child views could pass values to merge with the original meta array.
We can also add some fun things like easier title handling.