new site
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
# W4: fix mislocated hreflang="es" hrefs + add hreflang block to 3 ES category pages
|
||||
$repo = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$excludePattern = '\\(\.git|node_modules|seo-audit-2026-05-27|website|directory)\\'
|
||||
$files = Get-ChildItem $repo -Recurse -Filter index.html -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.FullName -notmatch $excludePattern }
|
||||
|
||||
$opts = [System.Text.RegularExpressions.RegexOptions]::IgnoreCase
|
||||
$changed = 0
|
||||
foreach ($file in $files) {
|
||||
$c = [System.IO.File]::ReadAllText($file.FullName)
|
||||
if (-not $c) { continue }
|
||||
$orig = $c
|
||||
# Strip /en/ /de/ /fr/ /pt/ /ar/ segment in any hreflang="es" or hreflang="x-default" href value
|
||||
$c = [regex]::Replace($c, '(hreflang="(?:es|x-default)"[^>]*href="https://www\.odoo-expertos\.com)/(?:de|fr|pt|ar|en)/', '$1/', $opts)
|
||||
# Also handle the inverse order: href=... hreflang=es
|
||||
$c = [regex]::Replace($c, '(href="https://www\.odoo-expertos\.com)/(?:de|fr|pt|ar|en)/([^"]*"\s+hreflang="(?:es|x-default)")', '$1/$2', $opts)
|
||||
if ($c -ne $orig) {
|
||||
[System.IO.File]::WriteAllText($file.FullName, $c)
|
||||
$changed++
|
||||
}
|
||||
}
|
||||
Write-Host "W4 hreflang-es fix: changed $changed of $($files.Count) files"
|
||||
|
||||
# Inject hreflang block into ES category pages
|
||||
$cats = @{
|
||||
'odoo' = 'odoo/'
|
||||
'odoo-hosting' = 'odoo-hosting/'
|
||||
'odoo-ia' = 'odoo-ia/'
|
||||
}
|
||||
$injected = 0
|
||||
foreach ($cat in $cats.Keys) {
|
||||
$catPath = Join-Path $repo "$cat\index.html"
|
||||
if (-not (Test-Path $catPath)) { continue }
|
||||
$c = [System.IO.File]::ReadAllText($catPath)
|
||||
if ($c -match 'hreflang=') { continue }
|
||||
$sub = $cats[$cat]
|
||||
$block = @"
|
||||
<!-- Hreflang alternates -->
|
||||
<link rel="alternate" hreflang="es" href="https://www.odoo-expertos.com/$sub">
|
||||
<link rel="alternate" hreflang="en" href="https://www.odoo-expertos.com/en/$sub">
|
||||
<link rel="alternate" hreflang="de" href="https://www.odoo-expertos.com/de/$sub">
|
||||
<link rel="alternate" hreflang="fr" href="https://www.odoo-expertos.com/fr/$sub">
|
||||
<link rel="alternate" hreflang="pt" href="https://www.odoo-expertos.com/pt/$sub">
|
||||
<link rel="alternate" hreflang="ar" href="https://www.odoo-expertos.com/ar/$sub">
|
||||
<link rel="alternate" hreflang="x-default" href="https://www.odoo-expertos.com/$sub">
|
||||
"@
|
||||
# Insert after canonical link
|
||||
$new = [regex]::Replace($c, '(<link\s+rel="canonical"[^>]*>)', "`$1`r`n$block", $opts)
|
||||
if ($new -eq $c) {
|
||||
# fallback: inject before </head>
|
||||
$new = $c -replace '</head>', "$block`r`n</head>"
|
||||
}
|
||||
if ($new -ne $c) {
|
||||
[System.IO.File]::WriteAllText($catPath, $new)
|
||||
$injected++
|
||||
Write-Host "Injected hreflang into $cat/index.html"
|
||||
}
|
||||
}
|
||||
Write-Host "W4 cat injection: $injected"
|
||||
Reference in New Issue
Block a user