Add comprehensive SEO optimization
All checks were successful
Deploy / Deploy to Production (push) Successful in 6s

Implement complete SEO setup for virtual product pages with:
- Meta tags (title, description, canonical, hreflang)
- Open Graph protocol for social sharing
- Twitter Card tags
- Schema.org structured data (JSON-LD) for products
- XML sitemap including virtual pages
- Dynamic meta tag updates via JavaScript

Changes:
- Create SEO snippet with all meta tags
- Add structured data snippet for products
- Generate sitemap.xml with products and hreflang
- Update meta tags dynamically when Shopify data loads
- Remove noindex/nofollow (was blocking all indexing)
- Add product-specific OG tags (price, availability)

All pages now properly indexed with correct multilingual setup.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-01-16 17:02:27 +01:00
parent f69d990349
commit 9eb8d08bcc
8 changed files with 271 additions and 6 deletions

View file

@ -22,6 +22,7 @@
}
renderProduct(product, isEnglish);
updateMetaTags(product, isEnglish);
loadingState.style.display = "none";
contentState.removeAttribute("style");
@ -224,4 +225,57 @@
}
}
}
function updateMetaTags(product, isEnglish) {
// Update title and description
const title = isEnglish && product.titleEn?.value
? product.titleEn.value
: product.title;
const description = isEnglish && product.descriptionEn?.value
? product.descriptionEn.value
: product.description;
// Update Open Graph title
const ogTitle = document.getElementById('og-title');
if (ogTitle) {
ogTitle.setAttribute('content', title);
}
// Update Open Graph description
const ogDescription = document.getElementById('og-description');
if (ogDescription && description) {
const excerpt = description.substring(0, 160);
ogDescription.setAttribute('content', excerpt);
}
// Update Open Graph image
const ogImage = document.getElementById('og-image');
if (ogImage && product.images.edges.length > 0) {
ogImage.setAttribute('content', product.images.edges[0].node.url);
}
// Update product price
const ogPrice = document.getElementById('og-price');
if (ogPrice) {
const price = parseFloat(product.priceRange.minVariantPrice.amount).toFixed(2);
ogPrice.setAttribute('content', price);
}
// Update availability
const ogAvailability = document.getElementById('og-availability');
if (ogAvailability) {
const availability = product.availableForSale ? 'in stock' : 'out of stock';
ogAvailability.setAttribute('content', availability);
}
// Update page title
document.title = `${title} | Index.ngo`;
// Update meta description
let metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription && description) {
const excerpt = description.substring(0, 160);
metaDescription.setAttribute('content', excerpt);
}
}
})();