Skip to content

danhendersonede/template-astro

Repository files navigation

Astro Project Template πŸš€

A modern, production-ready Astro project template with TypeScript, comprehensive tooling, and best practices built-in.

Astro TypeScript ESLint Prettier

✨ Features

  • 🎯 Astro v5.11.1 - Latest version with all modern features
  • πŸ”§ TypeScript - Strict configuration with path aliases
  • 🎨 Prettier - Code formatting with Astro plugin
  • πŸ” ESLint - Comprehensive linting with accessibility rules
  • πŸͺ Git Hooks - Pre-commit quality checks with Husky
  • πŸš€ Performance - View transitions, prefetching, image optimization
  • β™Ώ Accessibility - Built-in accessibility features and testing
  • πŸ“± SEO Ready - Meta tags, Open Graph social sharing
  • πŸ”„ CI/CD - GitHub Actions with quality checks
  • πŸ“ Organized - Clean project structure with conventions

πŸš€ Quick Start

1. Use This Template

# Create a new project from this template
npx degit danhendersonede/template-astro my-new-project
cd my-new-project

2. Set Up Your Project

# Install dependencies
npm install

# Customize your project configuration
# Edit src/config/site.ts with your project details

# Start development server
npm run dev

πŸ“ Important: Edit src/config/site.ts to customize:

  • Project name and description
  • Site URL and author information
  • Social media links
  • Navigation menu

πŸ“ Project Structure

/
β”œβ”€β”€ public/                 # Static assets
β”‚   └── favicon.svg
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/            # Build-time processed assets
β”‚   β”œβ”€β”€ components/        # Reusable components
β”‚   β”‚   └── SEOHead.astro  # SEO meta tags component
β”‚   β”œβ”€β”€ config/            # Configuration files
β”‚   β”‚   └── site.ts        # Site-wide configuration
β”‚   β”œβ”€β”€ content/           # Content collections
β”‚   β”‚   └── config.ts      # Content schema definitions
β”‚   β”œβ”€β”€ layouts/           # Layout components
β”‚   β”‚   └── Layout.astro   # Base layout with SEO
β”‚   β”œβ”€β”€ pages/             # File-based routing
β”‚   β”‚   β”œβ”€β”€ index.astro    # Homepage
β”‚   β”‚   β”œβ”€β”€ 404.astro      # Not found page
β”‚   β”‚   └── 500.astro      # Error page
β”‚   └── utils/             # Utility functions
β”‚       └── index.ts       # Common utilities
β”œβ”€β”€ .github/workflows/     # GitHub Actions CI/CD
β”œβ”€β”€ .husky/               # Git hooks
β”œβ”€β”€ .vscode/              # VS Code settings
β”œβ”€β”€ eslint.config.js      # ESLint configuration
β”œβ”€β”€ prettier.config.js    # Prettier configuration
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
└── astro.config.mjs      # Astro configuration

πŸ› οΈ Available Scripts

Command Description
npm run dev Start development server at localhost:4321
npm run build Build production site to ./dist/
npm run preview Preview production build locally
npm run check Run Astro type checking
npm run lint Run ESLint
npm run format Format code with Prettier

βš™οΈ Configuration

Site Configuration

Update src/config/site.ts to customize your site:

export const siteConfig: SiteConfig = {
  name: 'Your Project Name',
  title: 'Your Site Title',
  description: 'Your site description',
  url: 'https://your-domain.com',
  author: 'Your Name',
  social: {
    github: 'yourusername',
  },
  nav: [
    { label: 'Home', href: '/' },
    { label: 'About', href: '/about' },
  ],
};

Environment Variables

Copy .env.example to .env and update:

# Site Configuration
PUBLIC_SITE_URL=https://your-domain.com

# Analytics (optional)
PUBLIC_PLAUSIBLE_DOMAIN=your-domain.com

🎨 Customization

Adding New Pages

  1. Create .astro files in src/pages/
  2. Use the Layout component for consistency
  3. Add navigation links to src/config/site.ts

Creating Components

  1. Add components to src/components/
  2. Use TypeScript for props interfaces
  3. Follow Astro component conventions

Content Collections

Define content schemas in src/content/config.ts and add content files to src/content/[collection]/.

πŸ”§ Development Tools

VS Code Extensions

Recommended extensions (auto-suggested):

  • Astro
  • TypeScript Importer
  • ESLint
  • Prettier
  • Error Lens

Git Hooks

Pre-commit hooks automatically run:

  • Type checking
  • Linting with auto-fix
  • Code formatting
  • Build verification

πŸš€ Deployment

Vercel (Recommended)

npm i -g vercel
vercel

Netlify

npm run build
# Upload dist/ folder to Netlify

GitHub Pages

Enable GitHub Pages in repository settings and GitHub Actions will automatically deploy.

πŸ—οΈ Built With

πŸ“ License

This project is open source and available under the MIT License.

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ’‘ Tips

  • Update src/config/site.ts first for site-wide changes
  • Use TypeScript interfaces for better development experience
  • Leverage Astro's component islands for interactive elements
  • Keep accessibility in mind when adding new features
  • Test your changes across different devices and browsers

Built with ❀️ using Astro

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •