Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/carlosulisesochoa/astro-i18n-multilanguage-blog

Astro + Multilanguage (i18n) + Static Blog System Example
https://github.com/carlosulisesochoa/astro-i18n-multilanguage-blog

astro blog english i18n multilanguage spanish theme

Last synced: about 1 month ago
JSON representation

Astro + Multilanguage (i18n) + Static Blog System Example

Awesome Lists containing this project

README

        

# Astro 4 + Multilanguage (i18n) + Blog System Example

### Take a look at this basic but pretty and clean example

![ff](https://github.com/user-attachments/assets/3715d032-1057-4844-87b3-4c0322fc9f33)

## Features

- 🎨 Theme system (Light/Dark), it detect and set preferred browser theme
- 🌐 Language Switcher (ES/EN)
- ⛓️ Linked translations via a reference property: no need for matching slugs between locales.
- πŸ–οΈ Allow adding pages for a new locale with minimal effort; use the default locale\* as a fallback for missing settings and strings.
- 🏷️ Content tags Ñ la WordPress
- πŸ—ΊοΈ Sitemap support with translation links
- πŸ“‘ Localized RSS Feeds
- 🌍 Customizable URL structure, like `domain.tld/locale/directory/slug`
- πŸͺ½ Skip to content link for screen reader and keyboard users
- πŸ‘©β€πŸ’Ό Localized author profiles from a single data file
- πŸ” Secret/draft state to exclude posts from rendering
- πŸ”š 404 Page not found page
- 🐭 Ultra minimal styling without CSS classes with [new.css](https://newcss.net/) (remove only two lines of code to remove it!)
- πŸ”— `target="_blank"` for external links with [Rehype plugin](https://github.com/rehypejs/rehype-external-links)
- πŸ˜‰ Separate favicon for dev server to not get confused between dev and production
- βœ… 100/100 Lighthouse performance
- βœ… SEO-friendly with canonical URLs and OpenGraph data
- βœ… Markdown & MDX support

## πŸš€ Project Structure

You'll see the following folders and files:

```text
β”œβ”€β”€ public/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ components/
β”‚Β Β  β”œβ”€β”€ content/
β”‚Β Β  β”œβ”€β”€ i18n/
β”‚Β Β  β”‚ β”œβ”€β”€ i18n.ts ← Set up locales here
β”‚Β Β  β”‚ β”œβ”€β”€ uiStrings.js ← Localized headings, labels, etc.
β”‚Β Β  β”‚ └── utilities ← i18n-specific functions
β”‚Β Β  β”œβ”€β”€ layouts/
β”‚Β Β  β”œβ”€β”€ libs/
β”‚Β Β  β”œβ”€β”€ styles/
β”‚Β Β  β”œβ”€β”€ utilities/
β”‚Β Β  β”œβ”€β”€ consts.ts ← Settings loaded by astro.config.mjs
β”‚Β Β  β”œβ”€β”€ env.d.ts
β”‚Β Β  └── header.ts ← Settings for header menus, optionally per locale
β”œβ”€β”€ astro.config.mjs
β”œβ”€β”€ README.md
β”œβ”€β”€ package.json
└── tsconfig.json
```

Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.

There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

The `src/content/` directory contains collections of related markdown and MDX documents. A 'blog' collection has been defined already.

Any static assets, like images, can be placed in the `public/` directory.

## 🧞 Commands

All default commands can be run from the root of the project, from a terminal:

| Command | Action |
| :------------------------- | :----------------------------------------------- |
| `pnpm install` | Installs dependencies |
| `pnpm run dev` | Starts local dev server at `localhost:4321` |
| `pnpm run build` | Build your production site to `./dist/` |
| `pnpm run preview` | Preview your build locally, before deploying |
| `pnpm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `pnpm run astro -- --help` | Get help using the Astro CLI |

## βœ… TODO

You can check TODO-List at [TODO.md](./.github/TODO.md)

## Acknowledgements

- Special thanks to [@kslstn](https://github.com/kslstn) for the [astro-i18n-blog-starter](https://github.com/kslstn/astro-i18n-blog-starter), which served as a base for this version.