-
موقعیتهای استخدامی
+
@Model.PageHeading
@JalaliDate.ToPersianDigits(Model.Results.Count.ToString()) موقعیت شغلی پیدا شد
@if (Model.NearMeActive)
diff --git a/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs b/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs
index 5b339b9..8e42687 100644
--- a/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs
+++ b/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs
@@ -20,6 +20,10 @@ public class IndexModel : PageModel
[BindProperty(SupportsGet = true)] public double? Lat { get; set; }
[BindProperty(SupportsGet = true)] public double? Lng { get; set; }
+ // Pretty-URL segments (/استخدام/{roleSlug}/{citySlug?}); resolved to RoleId/CityId below.
+ [BindProperty(SupportsGet = true)] public string? RoleSlug { get; set; }
+ [BindProperty(SupportsGet = true)] public string? CitySlug { get; set; }
+
public bool NearMeActive => Lat is not null && Lng is not null;
public List Results { get; private set; } = new();
@@ -27,10 +31,29 @@ public class IndexModel : PageModel
public List Districts { get; private set; } = new();
public List Roles { get; private set; } = new();
- public async Task OnGetAsync()
+ /// Dynamic page heading/H1 + title, set from the active role/city for SEO.
+ public string PageHeading { get; private set; } = "موقعیتهای استخدامی";
+
+ public async Task OnGetAsync()
{
Cities = await _db.Cities.Where(c => c.IsActive).OrderBy(c => c.Name).ToListAsync();
Roles = await _db.Roles.Where(r => r.IsActive).OrderBy(r => r.SortOrder).ToListAsync();
+
+ // Pretty-URL landing: resolve slugs → filters. A slug matching nothing is a 404 (don't
+ // render a thin page under a junk URL).
+ if (!string.IsNullOrWhiteSpace(RoleSlug))
+ {
+ var role = Roles.FirstOrDefault(r => SeoSlug.Matches(r.Name, RoleSlug));
+ if (role is null) return NotFound();
+ RoleId = role.Id;
+ }
+ if (!string.IsNullOrWhiteSpace(CitySlug))
+ {
+ var city = Cities.FirstOrDefault(c => SeoSlug.Matches(c.Name, CitySlug));
+ if (city is null) return NotFound();
+ CityId = city.Id;
+ }
+
Districts = await _db.Districts
.Where(d => d.IsActive && (CityId == null || d.CityId == CityId))
.OrderBy(d => d.Name).ToListAsync();
@@ -63,5 +86,22 @@ public class IndexModel : PageModel
{
Results = results.OrderByDescending(j => j.CreatedAt).ToList();
}
+
+ SetSeo(Roles.FirstOrDefault(r => r.Id == RoleId)?.Name, Cities.FirstOrDefault(c => c.Id == CityId)?.Name);
+ return Page();
+ }
+
+ /// Title/H1/meta from the active role+city so the page targets «استخدام [نقش] [شهر]».
+ private void SetSeo(string? role, string? city)
+ {
+ PageHeading =
+ role is not null && city is not null ? $"استخدام {role} در {city}"
+ : role is not null ? $"استخدام {role}"
+ : city is not null ? $"استخدام کادر درمان در {city}"
+ : "موقعیتهای استخدامی";
+ ViewData["Title"] = PageHeading;
+ ViewData["Description"] = role is not null || city is not null
+ ? $"جدیدترین آگهیهای {PageHeading} در همکادر؛ مشاهده فرصتها و تماس مستقیم با مراکز درمانی."
+ : "موقعیتهای استخدامی کادر درمان (پزشک، پرستار، ماما، تکنسین) در بیمارستانها و کلینیکهای تهران — همکادر.";
}
}
diff --git a/src/JobsMedical.Web/Pages/Shifts/Index.cshtml b/src/JobsMedical.Web/Pages/Shifts/Index.cshtml
index ca28a2a..ce68bfc 100644
--- a/src/JobsMedical.Web/Pages/Shifts/Index.cshtml
+++ b/src/JobsMedical.Web/Pages/Shifts/Index.cshtml
@@ -1,12 +1,12 @@
@page
@model JobsMedical.Web.Pages.Shifts.IndexModel
@{
- ViewData["Title"] = "شیفتهای موجود";
+ // Title/description are set in the page model (SetSeo) from the active role/city.
}
-
شیفتهای موجود
+
@Model.PageHeading
@JalaliDate.ToPersianDigits(Model.Results.Count.ToString()) شیفت باز پیدا شد
@if (Model.NearMeActive)
diff --git a/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs b/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs
index 7d1b22a..d6133b3 100644
--- a/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs
+++ b/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs
@@ -25,6 +25,10 @@ public class IndexModel : PageModel
[BindProperty(SupportsGet = true)] public double? Lat { get; set; }
[BindProperty(SupportsGet = true)] public double? Lng { get; set; }
+ // Pretty-URL segments (/شیفت/{roleSlug}/{citySlug?}); resolved to RoleId/CityId below.
+ [BindProperty(SupportsGet = true)] public string? RoleSlug { get; set; }
+ [BindProperty(SupportsGet = true)] public string? CitySlug { get; set; }
+
public bool NearMeActive => Lat is not null && Lng is not null;
public List Results { get; private set; } = new();
@@ -33,12 +37,30 @@ public class IndexModel : PageModel
public List Roles { get; private set; } = new();
public List Facilities { get; private set; } = new();
- public async Task OnGetAsync()
+ /// Dynamic page heading/H1 + title, set from the active role/city for SEO.
+ public string PageHeading { get; private set; } = "شیفتهای خالی";
+
+ public async Task OnGetAsync()
{
var today = DateOnly.FromDateTime(DateTime.UtcNow);
Cities = await _db.Cities.Where(c => c.IsActive).OrderBy(c => c.Name).ToListAsync();
Roles = await _db.Roles.Where(r => r.IsActive).OrderBy(r => r.SortOrder).ToListAsync();
+
+ // Pretty-URL landing: resolve slugs → filters (404 on a slug that matches nothing).
+ if (!string.IsNullOrWhiteSpace(RoleSlug))
+ {
+ var role = Roles.FirstOrDefault(r => SeoSlug.Matches(r.Name, RoleSlug));
+ if (role is null) return NotFound();
+ RoleId = role.Id;
+ }
+ if (!string.IsNullOrWhiteSpace(CitySlug))
+ {
+ var city = Cities.FirstOrDefault(c => SeoSlug.Matches(c.Name, CitySlug));
+ if (city is null) return NotFound();
+ CityId = city.Id;
+ }
+
Districts = await _db.Districts
.Where(d => d.IsActive && (CityId == null || d.CityId == CityId))
.OrderBy(d => d.Name).ToListAsync();
@@ -82,5 +104,22 @@ public class IndexModel : PageModel
{
Results = results.OrderBy(s => s.Date).ThenBy(s => s.StartTime).ToList();
}
+
+ SetSeo(Roles.FirstOrDefault(r => r.Id == RoleId)?.Name, Cities.FirstOrDefault(c => c.Id == CityId)?.Name);
+ return Page();
+ }
+
+ /// Title/H1/meta from the active role+city so the page targets «شیفت [نقش] [شهر]».
+ private void SetSeo(string? role, string? city)
+ {
+ PageHeading =
+ role is not null && city is not null ? $"شیفت {role} در {city}"
+ : role is not null ? $"شیفت {role}"
+ : city is not null ? $"شیفت کادر درمان در {city}"
+ : "شیفتهای خالی";
+ ViewData["Title"] = PageHeading;
+ ViewData["Description"] = role is not null || city is not null
+ ? $"جدیدترین {PageHeading} در همکادر؛ مشاهده شیفتها و تماس مستقیم با مراکز درمانی."
+ : "شیفتهای خالی کادر درمان (پزشک، پرستار، ماما، تکنسین) در بیمارستانها و کلینیکهای تهران — همکادر.";
}
}
diff --git a/src/JobsMedical.Web/Pages/Talent/Index.cshtml b/src/JobsMedical.Web/Pages/Talent/Index.cshtml
index 7b50409..1633a1e 100644
--- a/src/JobsMedical.Web/Pages/Talent/Index.cshtml
+++ b/src/JobsMedical.Web/Pages/Talent/Index.cshtml
@@ -1,14 +1,13 @@
@page
@model JobsMedical.Web.Pages.Talent.IndexModel
@{
- ViewData["Title"] = "آماده به کار — کادر درمان";
- ViewData["Description"] = "فهرست کادر درمان آماده همکاری (پزشک، پرستار، ماما، تکنسین و…) در تهران و سایر شهرها — مرکز درمانی میتواند مستقیم تماس بگیرد.";
+ // Title/description are set in the page model (from the active role/city).
ViewData["q"] = Model.Q; // drives result highlighting in cards
}
-
آماده به کار
+
@Model.PageHeading
@JalaliDate.ToPersianDigits(Model.Results.Count.ToString()) نیروی کادر درمان آمادهی همکاری —
مراکز درمانی میتوانند مستقیم تماس بگیرند.
diff --git a/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs b/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs
index 264bc53..c12a8c2 100644
--- a/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs
+++ b/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs
@@ -23,6 +23,9 @@ public class IndexModel : PageModel
public List Districts { get; private set; } = new();
public List Roles { get; private set; } = new();
+ /// Dynamic page heading/H1 + title, set from the active role/city for SEO.
+ public string PageHeading { get; private set; } = "کادر درمان آماده به کار";
+
public async Task OnGetAsync()
{
Cities = await _db.Cities.Where(c => c.IsActive).OrderBy(c => c.Name).ToListAsync();
@@ -58,5 +61,15 @@ public class IndexModel : PageModel
}
Results = await q.OrderByDescending(t => t.CreatedAt).ToListAsync();
+
+ var role = Roles.FirstOrDefault(r => r.Id == RoleId)?.Name;
+ var city = Cities.FirstOrDefault(c => c.Id == CityId)?.Name;
+ PageHeading =
+ role is not null && city is not null ? $"{role} آماده به کار در {city}"
+ : role is not null ? $"{role} آماده به کار"
+ : city is not null ? $"کادر درمان آماده به کار در {city}"
+ : "کادر درمان آماده به کار";
+ ViewData["Title"] = PageHeading;
+ ViewData["Description"] = $"فهرست «آماده به کار» {(role ?? "کادر درمان")}{(city is not null ? " در " + city : "")} — همکادر؛ مشاهده و تماس مستقیم.";
}
}
diff --git a/src/JobsMedical.Web/Program.cs b/src/JobsMedical.Web/Program.cs
index b6e4544..a3b0dce 100644
--- a/src/JobsMedical.Web/Program.cs
+++ b/src/JobsMedical.Web/Program.cs
@@ -12,7 +12,13 @@ using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
-builder.Services.AddRazorPages();
+builder.Services.AddRazorPages(options =>
+{
+ // Pretty SEO landing routes that target «استخدام [نقش] [شهر]» / «شیفت …» searches, in addition
+ // to the query-string forms (/Jobs?RoleId=…&CityId=…). The page resolves the slugs to filters.
+ options.Conventions.AddPageRoute("/Jobs/Index", "استخدام/{roleSlug}/{citySlug?}");
+ options.Conventions.AddPageRoute("/Shifts/Index", "شیفت/{roleSlug}/{citySlug?}");
+});
// Interest tracking + recommendation engine.
builder.Services.AddHttpContextAccessor();
@@ -355,6 +361,31 @@ app.MapGet("/sitemap.xml", async (HttpContext ctx, AppDbContext db) =>
foreach (var fId in await db.Facilities.Select(f => f.Id).ToListAsync())
Url($"{b}/Facilities/Details/{fId}", null, "weekly");
+ // SEO landing pages: role-only and role×city combos that actually have live listings, so
+ // Google indexes pages targeting «استخدام [نقش] [شهر]» / «شیفت …». URL-encode each segment.
+ var roleNames = await db.Roles.ToDictionaryAsync(r => r.Id, r => r.Name);
+ var cityNames = await db.Cities.ToDictionaryAsync(c => c.Id, c => c.Name);
+ string Seg(string s) => Uri.EscapeDataString(s);
+ void Landing(string kind, int roleId, int? cityId)
+ {
+ if (!roleNames.TryGetValue(roleId, out var role)) return;
+ var loc = $"{b}/{Seg(kind)}/{Seg(SeoSlug.Of(role))}";
+ if (cityId is int c && cityNames.TryGetValue(c, out var city)) loc += $"/{Seg(SeoSlug.Of(city))}";
+ Url(loc, null, "daily");
+ }
+
+ var jobCombos = await db.JobOpenings
+ .Where(j => j.Status == ShiftStatus.Open && j.CreatedAt >= jobCutoff)
+ .Select(j => new { j.RoleId, j.Facility.CityId }).Distinct().ToListAsync();
+ foreach (var rid in jobCombos.Select(x => x.RoleId).Distinct()) Landing("استخدام", rid, null);
+ foreach (var x in jobCombos) Landing("استخدام", x.RoleId, x.CityId);
+
+ var shiftCombos = await db.Shifts
+ .Where(s => s.Status == ShiftStatus.Open && s.Date >= today)
+ .Select(s => new { s.RoleId, s.Facility.CityId }).Distinct().ToListAsync();
+ foreach (var rid in shiftCombos.Select(x => x.RoleId).Distinct()) Landing("شیفت", rid, null);
+ foreach (var x in shiftCombos) Landing("شیفت", x.RoleId, x.CityId);
+
sb.Append("");
return Results.Content(sb.ToString(), "application/xml");
});
diff --git a/src/JobsMedical.Web/Services/SeoSlug.cs b/src/JobsMedical.Web/Services/SeoSlug.cs
new file mode 100644
index 0000000..a0a8f09
--- /dev/null
+++ b/src/JobsMedical.Web/Services/SeoSlug.cs
@@ -0,0 +1,22 @@
+using System.Text.RegularExpressions;
+
+namespace JobsMedical.Web.Services;
+
+///
+/// Pretty-URL slugs for SEO landing pages (e.g. /استخدام/پزشک-عمومی/تهران). We keep Persian
+/// characters — Google indexes UTF-8 URLs fine and they read naturally — and just turn spaces into
+/// hyphens. Matching is tolerant of ي/ك, ZWNJ and hyphen/space variants so a hand-typed or
+/// search-engine-rewritten slug still resolves.
+///
+public static class SeoSlug
+{
+ /// The canonical slug for a role/city name («پزشک عمومی» → «پزشک-عمومی»).
+ public static string Of(string? name) => Key(name);
+
+ /// True when (from the URL) refers to .
+ public static bool Matches(string? name, string? slug) => Key(name) == Key(slug);
+
+ private static string Key(string? s) => Regex.Replace(
+ (s ?? "").Trim().Replace('ي', 'ی').Replace('ك', 'ک').Replace('', ' ').Replace('-', ' '),
+ @"\s+", "-").ToLowerInvariant();
+}