I'm building a laravel
-application where I want to include some schema.org
structured data. In my app.blade.php
- file, which is a layout file - I have included this:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name": "thecompany.com",
"alternateName": "the company",
"url": "{{ route('home') }}"
}
</script>
Now I want to add different parameters, pending on which subpage I am. For example I have a Job-listing page where I want each single jobpage to have something like:
{
"@context" : "https://schema.org/",
"@type" : "JobPosting",
"title" : "Software Engineer",
"description" : "<p>Become our next developer.</p>",
"employmentType" : "CONTRACTOR",
"hiringOrganization" : {
"@type" : "Organization",
"name" : "The Company",
"sameAs" : "http://www.google.com",
"logo" : "http://www.example.com/images/logo.png",
"baseSalary": {
"@type": "MonetaryAmount",
"currency": "USD",
"value": {
"@type": "QuantitativeValue",
"value": 40.00,
"unitText": "HOUR"
}
}
}
and the values change of course pending on which job page you are.
I tried to add the script in the job.blade.php
-file but it seems that it gets overridden by the script which is located in the app.blade.php
-file
How can I solve this?
Did you look into Blade components?
You could build a schema component with some defaults and include it on your job sites:
schema.blade.php
<script type="application/ld+json">
"@context" : "https://schema.org/",
{{ $slot }}
</script>
job.blade.php
@component('schema')
"@type" : "JobPosting",
"title" : "Software Engineer",
"description" : "<p>Become our next developer.</p>",
....
@endcomponent