Development

SEO Enhancement - agiusalexandre.com

Blog posts weren't appearing correctly in search results or showing rich previews when shared on social media.

Alexandre Agius

Alexandre Agius

AWS Solutions Architect

2 min read
Share:

The Problem

My blog posts weren’t appearing correctly in search results. When shared on social media, they showed generic previews instead of article-specific information. The site lacked the meta infrastructure that search engines and social platforms need to properly index and display content.

The Solution

Built a dedicated BlogLayout.astro component that wraps blog posts with comprehensive SEO infrastructure:

  • Open Graph tags for Facebook/LinkedIn previews
  • Twitter Card tags for Twitter previews
  • JSON-LD structured data for Google rich snippets
  • Canonical URLs to prevent duplicate content issues

How It Works

The JSON-LD structured data provides rich context to search engines:

const jsonLd = {
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": title,
  "description": description,
  "image": ogImage,
  "datePublished": isoDate,
  "dateModified": isoDate,
  "author": {
    "@type": "Person",
    "name": authorName,
    "url": authorLinkedIn,
    "jobTitle": "Senior Solutions Architect",
    "worksFor": {
      "@type": "Organization",
      "name": "Amazon Web Services"
    }
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": canonicalUrl
  }
};

Open Graph tags ensure proper social sharing previews:

<!-- Open Graph / Facebook -->
<meta property="og:type" content="article" />
<meta property="og:url" content={canonicalUrl} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={ogImage} />

<!-- Article specific Open Graph -->
<meta property="article:published_time" content={isoDate} />
<meta property="article:author" content={authorLinkedIn} />
{tags.map(tag => (
  <meta property="article:tag" content={tag} />
))}

Key Files Changed

FileChange
src/layouts/BlogLayout.astroNew SEO-optimized layout with full meta tags
src/pages/blog/[...slug].astroUpdated to use BlogLayout

What I Learned

  • Astro’s component model works well for SEO — The layout system allows centralized SEO configuration while keeping individual pages clean
  • JSON-LD is straightforward to implement — Using JavaScript objects that serialize to JSON makes structured data easy to maintain
  • Article-specific OG tags matter — article:published_time and article:tag provide richer context than generic og: tags

What’s Next

  • Add sitemap.xml generation for search engine crawling
  • Implement RSS feed for blog subscribers
  • Add structured data testing with Google’s Rich Results Test

Alexandre Agius

Alexandre Agius

AWS Solutions Architect

Passionate about AI & Security. Building scalable cloud solutions and helping organizations leverage AWS services to innovate faster. Specialized in Generative AI, serverless architectures, and security best practices.

Related Posts

Back to Blog