pnpm create astro@latest -- --template minimal🧑🚀 Seasoned astronaut? Delete this file. Have fun!
Inside of your Astro project, you'll see the following folders and files:
/
├── public/
├── src/
│ └── pages/
│ └── index.astro
└── package.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.
Any static assets, like images, can be placed in the public/ directory.
All commands are run from the root of the project, from a terminal:
| Command | Action |
|---|---|
pnpm install |
Installs dependencies |
pnpm dev |
Starts local dev server at localhost:4321 |
pnpm build |
Build your production site to ./dist/ |
pnpm preview |
Preview your build locally, before deploying |
pnpm astro ... |
Run CLI commands like astro add, astro check |
pnpm astro -- --help |
Get help using the Astro CLI |
Feel free to check our documentation or jump into our Discord server.
Here are the available commands for your Astro blog. To build the project:
pnpm buildThis will create a production-ready build in the dist/ directory. To preview the built site:
pnpm previewThis will serve the production build locally so you can test it before deploying. To run in development mode:
pnpm devThis runs the dev server with hot reloading (which you're likely already familiar with).
<mark style="background: #FFF3A3A6;"> (YELLOW)
<mark style="background: #BBFABBA6;"> (GREEN)
<mark style="background: #ba9375d9;"> -> <mark style="background:rgba(216, 192, 175, 0.85);"> (BROWN)
<mark style="background: #FFB8EBA6;"> (RED)
<mark style="background: #D2B3FFA6;"> (PURPLE)
<mark style="background: #FFB86CA6;"> (ORANGE)To migrate legacy mark tags from posts, use the scripts/migrate_marks.py script:
python3 scripts/migrate_marks.pyThis script scans src/content/posts for MDX files containing <mark> tags with specific background colors and replaces them with the <Highlight> component.
From time to time need to review:
- Obsidian links
[[and]]. - Obsidian images
![[.
Dockerfile: Utiliza una construcción "multi-stage" (multietapa).- Etapas de construcción: Usa Node.js para instalar dependencias y ejecutar pnpm run build.
- Etapa final: Copia solo la carpeta dist/ resultante a una imagen ligera de Nginx. Esto resulta en una imagen final muy pequeña y rápida, ideal para producción.
nginx.conf: Configuración para que Nginx sirva correctamente tus archivos estáticos, maneje las rutas de carpetas (estándar de Astro) y sirva tu página 404.html personalizada..dockerignore: Evita copiar node_modules y otros archivos innecesarios al contexto de Docker.
- Construir la imagen de Docker: Ejecuta el siguiente comando en la terminal (en la raíz de tu proyecto):
docker build -t my-aesthetic-blog .- Correr el contenedor una vez construida la imagen, iníciala mapeando el puerto 80 del contenedor al puerto que desees (por ejemplo, 8321):
docker run -d -p 8321:80 --name my-blog my-aesthetic-blogVerificalo abriendo tu navegador y visita http://localhost:8321.
- Si necesitas detener o eliminar el contenedor más tarde:
docker stop my-blogdocker
rm my-blogEstando ya dentro del servidor, lo más fácil es generar un par de llaves nuevo específico para GitHub Actions. Esto es más seguro que usar tus llaves personales.
Sigue estos pasos en tu terminal del servidor:
-
Genera las llaves (dale a Enter a todo para dejarlas sin contraseña, GitHub Actions no soporta llaves con contraseña fácilmente):
ssh-keygen -t ed25519 -C "github-actions" -f ~/.ssh/github_deploy_key
-
Autoriza la llave pública para que permita el acceso:
cat ~/.ssh/github_deploy_key.pub >> ~/.ssh/authorized_keys
-
Obtén la llave PRIVADA (esta es la que necesitas copiar):
cat ~/.ssh/github_deploy_key
Copia todo el bloque de texto que salga, incluyendo -----BEGIN OPENSSH PRIVATE KEY----- y -----END OPENSSH PRIVATE KEY-----. Ese bloque de texto es lo que debes pegar en el secreto SERVER_SSH_KEY en GitHub.
El deployment se activa automáticamente al subir un tag que comience con v (ejemplo: v1.0.0).
-
Crear un tag con la nueva versión:
git tag v1.0.0
-
Subir el tag a GitHub:
git push origin v1.0.0
Esto disparará el workflow de GitHub Actions que construye la imagen Docker y la despliega en el servidor.