Google for Jobs: only emit JobPosting JSON-LD for a real named employer
JobPosting requires a valid hiringOrganization; emitting «نامشخص / ثبت نشده» (the placeholder for aggregated ads with no named center) makes Google reject the posting and can flag invalid structured data across the site. Add SeoJsonLd.HasRealEmployer and gate the JobPosting/ShiftPosting <script> on it, so only listings with a genuine employer get marked up (those are the Jobs-eligible ones anyway). Improvement 3 of the backlog (SEO). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -197,6 +197,11 @@
|
||||
}
|
||||
|
||||
@section Head {
|
||||
@{ var bu = $"{ViewContext.HttpContext.Request.Scheme}://{ViewContext.HttpContext.Request.Host}"; }
|
||||
@* Only emit JobPosting structured data for a real named employer — Google for Jobs rejects a
|
||||
placeholder/empty hiringOrganization (most aggregated ads have no named center). *@
|
||||
@if (JobsMedical.Web.Services.SeoJsonLd.HasRealEmployer(f))
|
||||
{
|
||||
var bu = $"{ViewContext.HttpContext.Request.Scheme}://{ViewContext.HttpContext.Request.Host}";
|
||||
@Html.Raw("<script type=\"application/ld+json\">" + JobsMedical.Web.Services.SeoJsonLd.JobPosting(j, bu) + "</script>")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,10 @@
|
||||
}
|
||||
|
||||
@section Head {
|
||||
@{ var bu = $"{ViewContext.HttpContext.Request.Scheme}://{ViewContext.HttpContext.Request.Host}"; }
|
||||
@* Only for a real named employer — Google for Jobs rejects a placeholder hiringOrganization. *@
|
||||
@if (JobsMedical.Web.Services.SeoJsonLd.HasRealEmployer(f))
|
||||
{
|
||||
var bu = $"{ViewContext.HttpContext.Request.Scheme}://{ViewContext.HttpContext.Request.Host}";
|
||||
@Html.Raw("<script type=\"application/ld+json\">" + JobsMedical.Web.Services.SeoJsonLd.ShiftPosting(s, bu) + "</script>")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,12 @@ public static class SeoJsonLd
|
||||
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
|
||||
};
|
||||
|
||||
/// <summary>Whether a facility is a REAL named employer (not the «نامشخص» placeholder used for
|
||||
/// aggregated ads with no named center). Google for Jobs rejects a JobPosting whose
|
||||
/// hiringOrganization is empty/placeholder, so callers should skip the JSON-LD when this is false.</summary>
|
||||
public static bool HasRealEmployer(Facility? f)
|
||||
=> f is not null && !string.IsNullOrWhiteSpace(f.Name) && !f.Name.Contains("نامشخص") && !f.Name.Contains("ثبت نشده");
|
||||
|
||||
public static string ShiftPosting(Shift s, string baseUrl)
|
||||
{
|
||||
var typeLabel = s.ShiftType switch
|
||||
|
||||
Reference in New Issue
Block a user