Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abenevaut/39bb1bf0a4aef3334b13b74f28183820 to your computer and use it in GitHub Desktop.
Save abenevaut/39bb1bf0a4aef3334b13b74f28183820 to your computer and use it in GitHub Desktop.

Schema.org, top snippets for your portfolio or blog with spatie/schema-org

<?php
use Spatie\SchemaOrg\Schema;
$author = Schema::person()
->name('John Doe')
->image('john-doe.jpg')
->jobTitle('Web Developer')
->worksFor(Schema::organization()->name('Tech Solutions Inc.'))
->url('http://www.johndoe.com');
<?php
use Spatie\SchemaOrg\Schema;
$blogPost = Schema::blogPosting()
->headline('Titre de l\'article')
->datePublished('2023-06-01')
->author($author)
->articleBody('Contenu de l\'article...')
->image('http://www.example.com/images/article-image.jpg')
->publisher($organization);
$blog = Schema::blog()
->name('Le Blog de John Doe')
->blogPost($blogPost);
<?php
use Spatie\SchemaOrg\Schema;
$comment = Schema::comment()
->author(Schema::person()->name('Jane Doe'))
->datePublished('2023-06-02')
->text('Ceci est un commentaire sur l\'article.');
<?php
use Spatie\SchemaOrg\Schema;
$event = Schema::event()
->name('Conférence sur le Développement Web')
->startDate('2023-09-01T09:00')
->endDate('2023-09-01T17:00')
->location(Schema::place()->name('Centre des Congrès')->address('123 Rue Exemple, Paris, France'))
->organizer($author);
<?php
use Spatie\SchemaOrg\Schema;
$imageObject = Schema::imageObject()
->contentUrl('http://www.example.com/images/photo.jpg')
->creator($author)
->datePublished('2023-06-01')
->description('Une photo de démonstration');
<?php
use Spatie\SchemaOrg\Schema;
$localBusiness = Schema::localBusiness()
->name('Tech Solutions Inc.')
->address(
Schema::postalAddress()
->streetAddress('123 Rue Exemple')
->addressLocality('Paris')
->postalCode('75000')
->addressCountry('France')
)
->telephone('+33-1-23-45-67-89')
->url('http://www.techsolutions.com');
<?php
use Spatie\SchemaOrg\Schema;
$organization = Schema::organization()
->name('Tech Solutions Inc.')
->url('http://www.techsolutions.com')
->sameAs([
'http://www.facebook.com/techsolutions',
'http://www.twitter.com/techsolutions',
'http://www.linkedin.com/company/techsolutions'
]);
<?php
use Spatie\SchemaOrg\Schema;
$portfolioProject = Schema::creativeWork()
->name('Projet de Développement Web')
->creator($author)
->datePublished('2023-05-01')
->description('Description du projet...');
<?php
use Spatie\SchemaOrg\Schema;
$product = Schema::product()
->name('Produit Exemple')
->description('Description du produit exemple.')
->image('http://www.example.com/images/product.jpg')
->sku('12345')
->offers(
Schema::offer()
->price(29.99)
->priceCurrency('EUR')
->availability('http://schema.org/InStock')
);
<?php
use Spatie\SchemaOrg\Schema;
$service = Schema::service()
->name('Développement Web')
->description('Service de développement web complet')
->provider($author)
->areaServed(Schema::place()->name('France'))
->serviceType('Développement de site web');
<?php
use Spatie\SchemaOrg\Schema;
$termsOfService = Schema::termsOfService()
->name('Conditions Générales d\'Utilisation')
->datePublished('2023-06-01')
->mainEntityOfPage('Contenu des termes de service...');
<?php
use Spatie\SchemaOrg\Schema;
$videoObject = Schema::videoObject()
->name('Titre de la vidéo')
->description('Description de la vidéo')
->thumbnailUrl('http://www.example.com/images/video-thumbnail.jpg')
->uploadDate('2023-06-01')
->contentUrl('http://www.example.com/videos/video.mp4');
<?php
use Spatie\SchemaOrg\Schema;
$webPage = Schema::webPage()
->name('Accueil')
->description('Page d\'accueil de John Doe')
->url('http://www.johndoe.com')
->author($author);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment