mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
Merge branch 'master' of github.com:archtechx/laravel-seo
This commit is contained in:
commit
974f063a6a
1 changed files with 58 additions and 41 deletions
99
README.md
99
README.md
|
|
@ -1,4 +1,4 @@
|
|||
# laravel-seo
|
||||
# Laravel SEO
|
||||
|
||||
This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.
|
||||
|
||||
|
|
@ -166,48 +166,25 @@ The `flipp()` method also returns a signed URL to the image, which lets you use
|
|||
<img alt="@seo('title')" src="@seo('flipp', 'blog')">
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
This package is completely flexible, and can be customized either by having its views modified (to change the existing templates), or by you developing an extension (to add more templates).
|
||||
|
||||
### Views
|
||||
|
||||
You can publish the Blade views by running `php artisan vendor:publish --tag=seo-views`.
|
||||
|
||||
### Extensions
|
||||
|
||||
To use a custom extension, create a Blade *component* with the desired meta tags. The component should read data using `{{ seo()->get('foo') }}` or `@seo('foo')`.
|
||||
|
||||
For example:
|
||||
|
||||
```php
|
||||
<meta name="facebook-title" content="@seo('facebook.foo')">
|
||||
```
|
||||
|
||||
Once your view is created, register the extension:
|
||||
|
||||
```php
|
||||
seo()->extension('facebook', view: 'my-component')
|
||||
// The extension will use <x-my-component>
|
||||
```
|
||||
|
||||
To set data for an extension (in our case `facebook`), simply prefix calls with the extension name in camelCase, or use the `->set()` method:
|
||||
|
||||
```php
|
||||
seo()->facebookFoo('bar')
|
||||
seo()->facebookTitle('About us')
|
||||
seo()->set('facebook.description', 'We are a web development agency that ...')
|
||||
seo(['facebook.description' => 'We are a web development agency that ...'])
|
||||
```
|
||||
|
||||
To disable an extension, set the second argument in the `extension()` call to false:
|
||||
|
||||
```php
|
||||
seo()->extension('facebook', false);
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Service Provider
|
||||
|
||||
This example sets the default state in a service provider's `boot()` method:
|
||||
|
||||
```php
|
||||
seo()
|
||||
->site('ArchTech — Meticulously architected web applications')
|
||||
->title(
|
||||
default: 'ArchTech — Meticulously architected web applications',
|
||||
modify: fn (string $title) => $title . ' | ArchTech'
|
||||
)
|
||||
->description(default: 'We are a development agency ...')
|
||||
->image(default: fn () => asset('header.png'))
|
||||
->flipp('blog', 'o1vhcg5npgfu')
|
||||
->twitterSite('archtechx');
|
||||
```
|
||||
|
||||
### Controller
|
||||
|
||||
This example configures SEO metadata from a controller.
|
||||
|
|
@ -241,6 +218,46 @@ This example uses a Blade view that sets global SEO config using the values that
|
|||
</p>
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
This package is completely flexible, and can be customized either by having its views modified (to change the existing templates), or by you developing an extension (to add more templates).
|
||||
|
||||
### Views
|
||||
|
||||
You can publish the Blade views by running `php artisan vendor:publish --tag=seo-views`.
|
||||
|
||||
### Extensions
|
||||
|
||||
To use a custom extension, create a Blade *component* with the desired meta tags. The component should read data using `{{ seo()->get('foo') }}` or `@seo('foo')`.
|
||||
|
||||
For example:
|
||||
|
||||
```php
|
||||
<meta name="facebook-title" content="@seo('facebook.foo')">
|
||||
```
|
||||
|
||||
Once your view is created, register the extension:
|
||||
|
||||
```php
|
||||
seo()->extension('facebook', view: 'my-component');
|
||||
// The extension will use <x-my-component>
|
||||
```
|
||||
|
||||
To set data for an extension (in our case `facebook`), simply prefix calls with the extension name in camelCase, or use the `->set()` method:
|
||||
|
||||
```php
|
||||
seo()->facebookFoo('bar');
|
||||
seo()->facebookTitle('About us');
|
||||
seo()->set('facebook.description', 'We are a web development agency that ...');
|
||||
seo(['facebook.description' => 'We are a web development agency that ...']);
|
||||
```
|
||||
|
||||
To disable an extension, set the second argument in the `extension()` call to false:
|
||||
|
||||
```php
|
||||
seo()->extension('facebook', false);
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
Run all checks locally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue