Certainly! This is a very common issue when including raw curly braces ({}) and Blade syntax in view files. On your server, Blade is trying to interpret your JSON as Blade code (like {{ }} and @), especially if your server is set to a stricter parsing configuration or a different version of PHP/Blade.
Why does it work locally?
- Your local environment may have different versions of PHP or Blade, or more relaxed error reporting.
- Your server may have upgraded PHP or Blade, making it stricter or handling
{{--and{{differently.
How to Fix (Best Practice)
1. Use Blade's @verbatim Directive
The @verbatim ... @endverbatim directives tell Blade not to process anything inside. Put this around your schema code:
<!-- Website Schema -->
@verbatim
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "xxx",
"url": "https://example.test/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://example.test/?s={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
<!-- Organization Schema -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "xxx",
"url": "https://example.test/",
"logo": "https://example.test/front-end/images/logo.avif",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+91-999999999",
"contactType": "sales",
"areaServed": "IN",
"availableLanguage": ["English"]
},
"sameAs": [
"https://www.linkedin.com/company/xxx",
"https://www.facebook.com/xxx",
"https://www.youtube.com/channel/xxx"
]
}
</script>
@endverbatim
Why does this work?
Blade will ignore all curly braces and not try to interpret them as variables or Blade directives.
2. Other Recommendations
- You should quote all property values in JSON (as shown above), even URLs. This prevents syntax errors.
- When pasting large blocks of HTML or JS into Blade, always guard against accidental
{{ ... }}that Blade tries to process.
Summary
Wrap your JSON schema(s) in @verbatim ... @endverbatim in your partial file (and fix any missing or unquoted strings in the JSON as shown). This avoids Blade parsing issues both locally and on servers.
If you need to inject dynamic data, you can still do so with Blade outside of the @verbatim block or build the JSON in PHP/controller and pass as a variable.
Let me know if you need a version that mixes dynamic data!