From 9bc3fdec79738a94c9a268899ff7cb75a6023a6f Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Sat, 20 Jun 2026 18:03:14 +0330 Subject: [PATCH] Google for Jobs: only emit JobPosting JSON-LD for a real named employer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ") + @* 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("") + } } diff --git a/src/JobsMedical.Web/Pages/Shifts/Details.cshtml b/src/JobsMedical.Web/Pages/Shifts/Details.cshtml index 755cbd5..d14e055 100644 --- a/src/JobsMedical.Web/Pages/Shifts/Details.cshtml +++ b/src/JobsMedical.Web/Pages/Shifts/Details.cshtml @@ -216,6 +216,10 @@ } @section Head { - @{ var bu = $"{ViewContext.HttpContext.Request.Scheme}://{ViewContext.HttpContext.Request.Host}"; } - @Html.Raw("") + @* 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("") + } } diff --git a/src/JobsMedical.Web/Services/SeoJsonLd.cs b/src/JobsMedical.Web/Services/SeoJsonLd.cs index 6ceff92..2179f91 100644 --- a/src/JobsMedical.Web/Services/SeoJsonLd.cs +++ b/src/JobsMedical.Web/Services/SeoJsonLd.cs @@ -16,6 +16,12 @@ public static class SeoJsonLd DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull }; + /// 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. + 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