What is Astro?
Astro is a web framework that delivers the best performance by default through a unique architecture:- Zero JS by default - Astro strips out JavaScript automatically, sending only HTML and CSS to the browser
- Islands Architecture - Interactive components are isolated, only loading JavaScript where needed
- Component-agnostic - Use components from React, Vue, Svelte, or Astro’s own format
- Content-focused - Built specifically for content-rich sites like blogs and marketing pages
The Arte y Web Creaciones website uses Astro 5.12.1, which includes the latest performance improvements and features.
Why Astro for This Project?
Arte y Web Creaciones is a web design agency website that needs to:- Load blazingly fast - First impressions matter for potential clients
- Rank well in search engines - SEO is critical for lead generation
- Handle lots of content - Blog posts, service pages, and promotional content
- Be easy to maintain - Content updates should be simple
Project Configuration
The Astro configuration is defined inastro.config.mjs:
astro.config.mjs
Key Configuration Features
Site URL
Site URL
The This is used for:
site property defines the production URL:- Generating canonical URLs
- Creating the sitemap
- Building absolute URLs for RSS feeds
Custom Port
Custom Port
The development server runs on port 4322 instead of Astro’s default 4321:Access the dev server at
http://localhost:4322.URL Redirects
URL Redirects
Server-side redirects are configured for URL changes:These maintain SEO value when URLs change.
Sitemap Generation
Sitemap Generation
Automatically generates an XML sitemap with filtering:Thank you pages and form submission pages are excluded from the sitemap.
Integrations
The project uses four official Astro integrations:1. Sitemap (@astrojs/sitemap)
@astrojs/sitemap
Generates XML sitemaps automatically
/sitemap-index.xml for search engines to discover all pages.
2. Tailwind CSS (@astrojs/tailwind)
@astrojs/tailwind
Integrates Tailwind CSS utility framework
tailwind.config.mjs.
3. MDX (@astrojs/mdx)
@astrojs/mdx
Use JSX components in Markdown content
src/content/blog/example.md
4. Astro Icon (astro-icon)
astro-icon
Flexible icon system with 100,000+ icons
@iconify-json/mdi.
Astro Components
Astro’s component format (.astro files) is the core building block of this project. Here’s the anatomy of an Astro component:
src/components/Alert.astro
Component Structure
Frontmatter (Component Script)
The area between
--- fences contains JavaScript/TypeScript that runs at build time:- Import other components and utilities
- Define TypeScript interfaces for props
- Process data and compute values
- Fetch content from collections
Template (HTML)
The HTML-like template that defines the component’s structure:
- Use standard HTML elements
- Include other components
- Insert JavaScript expressions with
{} - Use
<slot />for content projection
File-Based Routing
Astro uses file-based routing - the file structure insrc/pages/ determines your URL structure:
Dynamic Routes
The blog uses a dynamic route with[...slug].astro:
src/pages/blog/[...slug].astro
/blog/10-pasos-para-crear-tu-web-profesional/blog/cuanto-cuesta-una-pagina-web- And all other blog posts from the content collection
The Layout Pattern
The project uses a main layout wrapper (Layout.astro) that all pages use:
src/layouts/Layout.astro
src/pages/contacto.astro
- Consistent navigation and footer
- SEO meta tags and Open Graph
- Google Analytics and Tag Manager
- Schema.org structured data
- Cookie consent banner
Build Process
When you runnpm run build, Astro:
- Processes all components - Runs component scripts at build time
- Fetches content - Loads all content collections
- Generates static HTML - Creates optimized HTML files
- Optimizes assets - Processes images, CSS, and minimal JavaScript
- Creates routes - Generates all static and dynamic pages
The result is a fully static site with no runtime dependencies. It can be hosted on any static hosting service like Netlify, Vercel, or even a simple web server.
Output
The build creates adist/ directory:
Performance Benefits
Zero JavaScript by Default
Astro sends pure HTML and CSS. No framework runtime overhead.
Partial Hydration
Only interactive components load JavaScript, using Astro’s Islands Architecture.
Build-Time Rendering
All pages are pre-rendered at build time for instant loading.
Optimized Assets
Automatic CSS minification and image optimization with Sharp.
Next Steps
Content Collections
Learn how content is structured with type-safe schemas
Component Architecture
Explore how components are organized and used
Further Reading
Astro Documentation
Official Astro documentation with comprehensive guides