From aba0dc78434df3eb47e5c4779b19e317940bfaf9 Mon Sep 17 00:00:00 2001 From: unibox Date: Tue, 30 Jun 2026 14:25:26 +0200 Subject: [PATCH 1/6] add translated deno.mdx in it/guides/deploy --- src/content/docs/it/deploy/deno.mdx | 354 ++++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 src/content/docs/it/deploy/deno.mdx diff --git a/src/content/docs/it/deploy/deno.mdx b/src/content/docs/it/deploy/deno.mdx new file mode 100644 index 0000000000000..ad0cfcb2562fe --- /dev/null +++ b/src/content/docs/it/deploy/deno.mdx @@ -0,0 +1,354 @@ +--- +title: Distribuisci il tuo sito Astro con Deno +description: Come distribuire il tuo sito Astro sul Web usando Deno. +sidebar: + label: Deno Deploy +type: deploy +logo: deno +supports: ['ssr', 'static'] +i18nReady: true +--- +import { Steps } from '@astrojs/starlight/components'; +import StaticSsrTabs from '~/components/tabs/StaticSsrTabs.astro'; +import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro' + +Puoi distribuire un sito Astro statico o renderizzato on-demand usando Deno, sia sul tuo stesso server, o su [Deno Deploy](https://deno.com/deploy), un sistema distribuito che esegue JavaScript, TypeScript, e al limite WebAssembly, in tutto il mondo. + +Questa guida include le istruzioni per eseguire il tuo sito Astro sul tuo stesso server con Deno, e distribuire su Deno Deploy attraverso GitHub Actions o Deno Deploy CLI. + +## Requisiti + +Questa guida presuppone che hai già [Deno](https://deno.com/) intallato. + +## Configurazione Del Progetto + +Il tuo progetto Astro può essere distribuito come sito statico, o come sito renderizzato on-demand. + +### Sito Statico + +Il tuo progetto Astro, per impostazione predefinta, è un sito statico. Non hai bisogno di configurazioni extra per distribuire un sito Astro statico con Deno, o su Deno Deploy. + +### Adattatore per il rendering on-demand + +Per abilitare il rendering on-demand nel tuo progetto Astro usando Deno, e per distribuirlo su Deno Deploy: + + +1. Installa [l'adattatore `@deno/astro-adapter`][Adattatore Deno] nelle tue dipendenze del progetto usando il tuo package manager preferito: + + + + ```shell + npm install @deno/astro-adapter + ``` + + + ```shell + pnpm install @deno/astro-adapter + ``` + + + ```shell + yarn add @deno/astro-adapter + ``` + + + +2. Aggiorna il tuo file di configuratione del progetto `astro.config.mjs` con le seguenti modifiche. + + ```js ins={3,6-7} + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import deno from '@deno/astro-adapter'; + + export default defineConfig({ + output: 'server', + adapter: deno(), + }); + ``` + +3. Aggiorna il tuo script `preview` in `package.json` con le seguenti modifiche. + + ```json del={8} ins={9} + // package.json + { + // ... + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview" + "preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs" + } + } + ``` + + Puoi ora usare questo comando per vedere l'anteprima del tuo sito Astro di produzione localmente con Deno. + + + + ```shell + npm run preview + ``` + + + ```shell + pnpm run preview + ``` + + + ```shell + yarn run preview + ``` + + + + +## Come distribuire + +Puoi eseguire il tuo sito Astro sul tuo stesso server, o distribuirlo su Deno Deploy attraverso GitHub Actions o usando Deno Deploy’s CLI (interfaccia a linea di comando). + +### Sul tuo stesso server + + +1. Copia il tuo progetto sul tuo server. + +2. Installa le dipendenze del progetto usando il tuo package manager preferito: + + + + ```shell + npm install + ``` + + + ```shell + pnpm install + ``` + + + ```shell + yarn + ``` + + + +3. Compila il tuo sito Astro con il tuo package manager preferito: + + + + ```shell + npm run build + ``` + + + ```shell + pnpm run build + ``` + + + ```shell + yarn run build + ``` + + + +4. Avvia la tua applicazione con il comando seguente: + + + + ```bash + deno run -A jsr:@std/http/file-server dist + ``` + + + + ```bash + deno run -A ./dist/server/entry.mjs + ``` + + + + +### Distribuzione Con GitHub Actions + +Se il tuo progetto è salvato su GitHub, il [sito web Deno Deploy](https://dash.deno.com/) ti guiderà nell'impostare le GitHub Actions per distribuire il tuo sito Astro. + + +1. Invia il tuo codice su un repository Github pubblico o privato. + +2. Accedi a [Deno Deploy](https://dash.deno.com/) con il tuo account GitHub, e clicca su [Nuovo Progetto](https://dash.deno.com). + +3. Seleziona il tuo repository, il branch che vuoi distribuire, e seleziona la modalità **GitHub Action**. (Il tuo sito Astro richiede un passaggio di compilazione, e non può usare la modalità Automatica.) + +4. Nel tuo progetto Astro, crea un nuovo file in `.github/workflows/deploy.yml` e incollaci il seguente YAML. Questo è simile allo YAML dato da Deno Deploy, con i passaggi addizionali necessari al tuo sito Astro. + + + + ```yaml + --- + // .github/workflows/deploy.yml + --- + name: Deploy + on: [push] + + jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + permissions: + id-token: write # Needed for auth with Deno Deploy + contents: read # Needed to clone the repository + + steps: + - name: Clone repository + uses: actions/checkout@v6 + + # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` + - name: Install dependencies + run: npm ci + + # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` + - name: Build Astro + run: npm run build + + - name: Upload to Deno Deploy + uses: denoland/deployctl@v1 + with: + project: my-deno-project # TODO: replace with Deno Deploy project name + entrypoint: jsr:@std/http/file-server + root: dist + ``` + + + + ```yaml + --- + // .github/workflows/deploy.yml + --- + name: Deploy + on: [push] + + jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + permissions: + id-token: write # Needed for auth with Deno Deploy + contents: read # Needed to clone the repository + + steps: + - name: Clone repository + uses: actions/checkout@v6 + + # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` + - name: Install dependencies + run: npm ci + + # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` + - name: Build Astro + run: npm run build + + - name: Upload to Deno Deploy + uses: denoland/deployctl@v1 + with: + project: my-deno-project # TODO: replace with Deno Deploy project name + entrypoint: dist/server/entry.mjs + ``` + + + +5. Dopo aver effettuato il commit di questo file YAML, e inviato a GitHub sul tuo branch configurato per la distribuzione, la distribuzione dovrebbe iniziare automaticamente! + + Puoi monitorare il progresso usando la scheda "Actions" sulla pagina del tuo repository GitHub, o su [Deno Deploy](https://dash.deno.com). + + +### Distribuzione CLI + + +1. Installa [Deno Deploy CLI](https://docs.deno.com/deploy/manual/deployctl). + + ```bash + deno install -gArf jsr:@deno/deployctl + ``` + +2. Compila il tuo sito Astro con il tuo package manager preferito: + + + + ```shell + npm run build + ``` + + + ```shell + pnpm run build + ``` + + + ```shell + yarn run build + ``` + + + +3. Esegui `deployctl` per distribuire! + + + + ```bash + cd dist && deployctl deploy jsr:@std/http/file-server + ``` + + + + ```bash + deployctl deploy ./dist/server/entry.mjs + ``` + + + + Puoi monitorare tutte le tue distribuzioni su [Deno Deploy](https://dash.deno.com). + +4. (Opzionale) Per semplificare la compilazione e la distribuzione in un comando, aggiungi uno script `deploy-deno` in `package.json`. + + + + ```json ins={9} + // package.json + { + // ... + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview", + "deno-deploy": "npm run build && cd dist && deployctl deploy jsr:@std/http/file-server" + } + } + ``` + + + ```json ins={9} + // package.json + { + // ... + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs", + "deno-deploy": "npm run build && deployctl deploy ./dist/server/entry.mjs" + } + } + ``` + + + + Quindi puoi usare questo comando per compilare e distribuire il tuo sito Astro in un passaggio. + + ```bash + npm run deno-deploy + ``` + + +[Adattatore Deno]: https://github.com/denoland/deno-astro-adapter From eecaffc27f1b4edf0c1ad19c8effe5ec526f61be Mon Sep 17 00:00:00 2001 From: unibox Date: Tue, 30 Jun 2026 14:37:55 +0200 Subject: [PATCH 2/6] add guides folder --- src/content/docs/it/{ => guides}/deploy/deno.mdx | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/content/docs/it/{ => guides}/deploy/deno.mdx (100%) diff --git a/src/content/docs/it/deploy/deno.mdx b/src/content/docs/it/guides/deploy/deno.mdx similarity index 100% rename from src/content/docs/it/deploy/deno.mdx rename to src/content/docs/it/guides/deploy/deno.mdx From fd6494c3370261d1862dbed93ae2144278ee4d7b Mon Sep 17 00:00:00 2001 From: unibox Date: Wed, 1 Jul 2026 20:59:39 +0200 Subject: [PATCH 3/6] translate comments --- src/content/docs/en/guides/deploy/deno.mdx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/content/docs/en/guides/deploy/deno.mdx b/src/content/docs/en/guides/deploy/deno.mdx index 2597a816fdc36..5e6a3c90e18f6 100644 --- a/src/content/docs/en/guides/deploy/deno.mdx +++ b/src/content/docs/en/guides/deploy/deno.mdx @@ -196,25 +196,25 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + id-token: write # Necessario per l'autenticazione con Deno Deploy + contents: read # Necessario per clonare il repository steps: - name: Clone repository uses: actions/checkout@v6 - # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` + # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` - name: Install dependencies run: npm ci - # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` + # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: replace with Deno Deploy project name + project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy entrypoint: jsr:@std/http/file-server root: dist ``` @@ -233,25 +233,25 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + id-token: write # Necessario per l'autenticazione con Deno Deploy + contents: read # Necessario per clonare il repository steps: - name: Clone repository uses: actions/checkout@v6 - # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` + # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` - name: Install dependencies run: npm ci - # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` + # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: replace with Deno Deploy project name + project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy entrypoint: dist/server/entry.mjs ``` From ad001570f3b05d2a6210a31e5309b12d3e6a2ee7 Mon Sep 17 00:00:00 2001 From: unibox Date: Wed, 1 Jul 2026 21:09:34 +0200 Subject: [PATCH 4/6] translate comments --- src/content/docs/en/guides/deploy/deno.mdx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/content/docs/en/guides/deploy/deno.mdx b/src/content/docs/en/guides/deploy/deno.mdx index 192c0fd57bbf3..2329ed48a3870 100644 --- a/src/content/docs/en/guides/deploy/deno.mdx +++ b/src/content/docs/en/guides/deploy/deno.mdx @@ -195,25 +195,25 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + id-token: write # Necessario per l'autenticazione con Deno Deploy + contents: read # Necessario per clonare il repository steps: - name: Clone repository uses: actions/checkout@v6 - # Not using npm? Change `npm ci` to `pnpm i` or `yarn install` + # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` - name: Install dependencies run: npm ci - # Not using npm? Change `npm run build` to `pnpm run build` or `yarn run build` + # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: replace with Deno Deploy project name + project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy entrypoint: jsr:@std/http/file-server root: dist ``` @@ -232,25 +232,25 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + id-token: write # Necessario per l'autenticazione con Deno Deploy + contents: read # Necessario per clonare il repository steps: - name: Clone repository uses: actions/checkout@v6 - # Not using npm? Change `npm ci` to `pnpm i` or `yarn install` + # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` - name: Install dependencies run: npm ci - # Not using npm? Change `npm run build` to `pnpm run build` or `yarn run build` + # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: replace with Deno Deploy project name + project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy entrypoint: dist/server/entry.mjs ``` From b4395ab432a7da8a2c88992370e7d8028d0a70f2 Mon Sep 17 00:00:00 2001 From: unibox Date: Thu, 2 Jul 2026 06:51:43 +0200 Subject: [PATCH 5/6] restore english file and translate italian file --- src/content/docs/en/guides/deploy/deno.mdx | 89 ++++++++++------------ src/content/docs/it/guides/deploy/deno.mdx | 20 ++--- 2 files changed, 49 insertions(+), 60 deletions(-) diff --git a/src/content/docs/en/guides/deploy/deno.mdx b/src/content/docs/en/guides/deploy/deno.mdx index 2329ed48a3870..2597a816fdc36 100644 --- a/src/content/docs/en/guides/deploy/deno.mdx +++ b/src/content/docs/en/guides/deploy/deno.mdx @@ -33,7 +33,7 @@ Your Astro project is a static site by default. You don’t need any extra confi To enable on-demand rendering in your Astro project using Deno, and to deploy on Deno Deploy: -1. Install [the `@deno/astro-adapter` adapter][deno-adapter] to your project’s dependencies using your preferred package manager: +1. Install [the `@deno/astro-adapter` adapter][Deno adapter] to your project’s dependencies using your preferred package manager: @@ -68,9 +68,10 @@ To enable on-demand rendering in your Astro project using Deno, and to deploy on 3. Update your `preview` script in `package.json` with the change below. - ```json del={7} ins={8} + ```json del={8} ins={9} // package.json { + // ... "scripts": { "dev": "astro dev", "start": "astro dev", @@ -126,7 +127,7 @@ You can run your Astro site on your own server, or deploy to Deno Deploy through ```shell - yarn install + yarn ``` @@ -195,25 +196,25 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Necessario per l'autenticazione con Deno Deploy - contents: read # Necessario per clonare il repository + id-token: write # Needed for auth with Deno Deploy + contents: read # Needed to clone the repository steps: - name: Clone repository uses: actions/checkout@v6 - # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` + # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` - name: Install dependencies run: npm ci - # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` + # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy + project: my-deno-project # TODO: replace with Deno Deploy project name entrypoint: jsr:@std/http/file-server root: dist ``` @@ -232,25 +233,25 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Necessario per l'autenticazione con Deno Deploy - contents: read # Necessario per clonare il repository + id-token: write # Needed for auth with Deno Deploy + contents: read # Needed to clone the repository steps: - name: Clone repository uses: actions/checkout@v6 - # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` + # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` - name: Install dependencies run: npm ci - # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` + # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy + project: my-deno-project # TODO: replace with Deno Deploy project name entrypoint: dist/server/entry.mjs ``` @@ -308,58 +309,46 @@ If your project is stored on GitHub, the [Deno Deploy website](https://dash.deno You can track all your deploys on [Deno Deploy](https://dash.deno.com). -4. (Optional) To simplify the build and deploy into one command, add a `deploy-deno` script in `package.json`, adapting it for your preferred package manager. +4. (Optional) To simplify the build and deploy into one command, add a `deploy-deno` script in `package.json`. - ```json ins={8} + ```json ins={9} // package.json { + // ... "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "astro preview", - "deno-deploy": "npm run build && cd dist && deployctl deploy jsr:@std/http/file-server" + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview", + "deno-deploy": "npm run build && cd dist && deployctl deploy jsr:@std/http/file-server" } } ``` - ```json ins={8} - // package.json - { - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs", - "deno-deploy": "npm run build && deployctl deploy ./dist/server/entry.mjs" - } - } - ``` + ```json ins={9} + // package.json + { + // ... + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs", + "deno-deploy": "npm run build && deployctl deploy ./dist/server/entry.mjs" + } + } + ``` Then you can use this command to build and deploy your Astro site in one step. - - - ```shell - npm run deno-deploy - ``` - - - ```shell - pnpm run deno-deploy - ``` - - - ```shell - yarn run deno-deploy - ``` - - + ```bash + npm run deno-deploy + ``` -[deno-adapter]: https://github.com/denoland/deno-astro-adapter +[Deno adapter]: https://github.com/denoland/deno-astro-adapter diff --git a/src/content/docs/it/guides/deploy/deno.mdx b/src/content/docs/it/guides/deploy/deno.mdx index ad0cfcb2562fe..18e5063426003 100644 --- a/src/content/docs/it/guides/deploy/deno.mdx +++ b/src/content/docs/it/guides/deploy/deno.mdx @@ -196,25 +196,25 @@ Se il tuo progetto è salvato su GitHub, il [sito web Deno Deploy](https://dash. name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + id-token: write # Necessario per l'autenticazione con Deno Deploy + contents: read # Necessario per clonare il repository steps: - name: Clone repository uses: actions/checkout@v6 - # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` + # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` - name: Install dependencies run: npm ci - # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` + # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: replace with Deno Deploy project name + project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy entrypoint: jsr:@std/http/file-server root: dist ``` @@ -233,25 +233,25 @@ Se il tuo progetto è salvato su GitHub, il [sito web Deno Deploy](https://dash. name: Deploy runs-on: ubuntu-latest permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + id-token: write # Necessario per l'autenticazione con Deno Deploy + contents: read # Necessario per clonare il repository steps: - name: Clone repository uses: actions/checkout@v6 - # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` + # Non usi npm? Sostituisci `npm ci` con `yarn install` o `pnpm i` - name: Install dependencies run: npm ci - # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` + # Non usi npm? Sostituisci `npm run build` con `yarn build` o `pnpm run build` - name: Build Astro run: npm run build - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: my-deno-project # TODO: replace with Deno Deploy project name + project: my-deno-project # TODO: sostituisci con il nome del progetto di Deno Deploy entrypoint: dist/server/entry.mjs ``` From 1a8cd8d226f642db26c4ecfb992ffa0e488e89fc Mon Sep 17 00:00:00 2001 From: unibox Date: Fri, 10 Jul 2026 13:58:24 +0200 Subject: [PATCH 6/6] add it/guides/deploy/github.mdx --- src/content/docs/it/guides/deploy/github.mdx | 165 +++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 src/content/docs/it/guides/deploy/github.mdx diff --git a/src/content/docs/it/guides/deploy/github.mdx b/src/content/docs/it/guides/deploy/github.mdx new file mode 100644 index 0000000000000..194a05389ca87 --- /dev/null +++ b/src/content/docs/it/guides/deploy/github.mdx @@ -0,0 +1,165 @@ +--- +title: Distribuisci il tuo sito Astro su GitHub Pages +description: Come distribuire il tuo sito Astro sul web usando GitHub Pages. +sidebar: + label: GitHub Pages +type: deploy +logo: github +supports: ['static'] +i18nReady: true +--- +import { Steps } from '@astrojs/starlight/components'; + +Puoi usare [GitHub Pages](https://pages.github.com/) per ospitare un sito web Astro statico e prerenderizzato, direttamente da un repository su [GitHub.com](https://github.com/) usando [GitHub Actions](https://github.com/features/actions). + +## Come distribuire + +Astro mantiene un'[Action GitHub Astro ufficiale per distribuire il tuo progetto su un GitHub Pages](https://github.com/withastro/action) con una minima configurazione ed è il modo raccomandato per distribuire su GitHub Pages. + +Segui le istruzioni che seguono per usare GitHub Action per distribuire il tuo sito Astro su GitHub Pages. Questo creerà un sito web dal tuo repository con un URL GitHub (e.g. `https://.github.io/`). Una volta distribuito, puoi opzionalmente [configurare un dominio personalizzato](#cambia-il-tuo-url-github-in-un-dominio-personalizzato) per distribuire il tuo sito su GitHub Pages con il tuo dominio preferito (e.g. `https://example.com`). + + +1. Crea un nuovo file nel tuo progetto in `.github/workflows/deploy.yml` e incollaci lo YAML seguente. + + ```yaml title="deploy.yml" + name: Deploy to GitHub Pages + + on: + # Attiva il workflow ogni volta che fai il push del ramo `main` + # Usi un nome di ramo differente? Sostituisci `main` con il nome del tuo ramo + push: + branches: [ main ] + # Ti permette di eseguire questo workflow manualmente dalle Actions tab su GitHub. + workflow_dispatch: + + # Permette a questo lavoro di clonare il repo e creare una distribuzione della pagina + permissions: + contents: read + pages: write + id-token: write + + jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout your repository using git + uses: actions/checkout@v6 + - name: Install, build, and upload your site + uses: withastro/action@v6 + # with: + # path: . # La posizione principale del tuo progetto Astro nel repository. (opzionale) + # node-version: 24 # La versione specifica di Node che dovrebbe essere usata per compilare il tuo sito. Di default è 24. (opzionale) + # package-manager: pnpm@latest # Il gestore di pacchetti che dovrebbe essere usato per installare le dipendenze e compilare il tuo sito. Rilevato automaticamente in base al tuo lockfile. (opzionale) + # build-cmd: pnpm run build # Il comando da eseguire per compilare il tuo sito. Di default esegue lo script/task di compilazione del package. (opzionale) + # env: + # PUBLIC_POKEAPI: 'https://pokeapi.co/api/v2' # Usa le virgolette singole per il valore della variabile. (opzionale) + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 + ``` + + L'action Astro può essere configurata con input opzionali. Forniscili decommentando la linea `with:` e l'input che vuoi usare. + + Se il tuo sito richiede delle variabili d'ambiente pubbliche, decommenta la linea `env:` e aggiungile là. (Vedi la [documentazione GitHub su come impostare i segreti](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#creating-configuration-variables-for-a-repository) per aggiungere variabili d'ambiente private.) + + :::caution[Attenzione] + L'[action] Astro ufficiale (https://github.com/withastro/action) cerca un lockfile per individuare il tuo package manager preferito (`npm`, `yarn`, `pnpm`, or `bun`). Dovresti eseguire il commit sul tuo repository del file `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, o `bun.lockb` generato automaticamente dal tuo package manager. + ::: + +2. Nel tuo file di configurazione di Astro, imposta [`site`](/it/reference/configuration-reference/#site) sull'URL GitHub del tuo sito distribuito. + + ```js title="astro.config.mjs" ins={4} + import { defineConfig } from 'astro/config' + + export default defineConfig({ + site: 'https://astronaut.github.io', + }) + ``` + + Il valore di `site` deve essere uno dei seguenti: + + - Il seguente URL basato sul tuo username: `https://.github.io` + - L'URL casuale autogenerato per una [pagina privata dell'Organizzazione di GitHub](https://docs.github.com/en/enterprise-cloud@latest/pages/getting-started-with-github-pages/changing-the-visibility-of-your-github-pages-site): `https://.pages.github.io/` + +3. In `astro.config.mjs`, configura un valore per [`base`](/it/reference/configuration-reference/#base) (solitamente richiesto). + + GitHub Pages pubblicherà il tuo sito web con un indirizzo che dipende sia dal tuo username che dal nome del repository (e.g. `https://.github.io//`). Imposta un valore per `base` che specifichi il repository per il tuo sito web. È così che Astro capisce che la posizione principale del tuo sito web è `/my-repo`, invece del predefinito `/`. Puoi saltarlo se il nome del tuo repository corrisponde al pattern speciale `.github.io` (e.g. `https://github.com/username/username.github.io/`) + + Configura `base` come il nome del repository iniziando con un barra (e.g. `/my-repo`): + + ```js title="astro.config.mjs" ins={4-5} + import { defineConfig } from 'astro/config' + + export default defineConfig({ + site: 'https://astronaut.github.io', + base: '/my-repo', + }) + ``` + + :::caution[link interni con `base` configurato] + Quando questo valore è configurato, tutti i tuoi link interni di pagina devono essere preceduti dal valore di `base`: + + ```astro ins="/my-repo" + About + ``` + + Vedi di più su come [configurare un valore di `base`](/it/reference/configuration-reference/#base). + ::: + +4. Su GitHub, vai sulla tab **settings** del tuo repository e trova la sezione **Pages** delle impostazioni. + +5. Scegli **GitHub Actions** come **Fonte** del tuo sito. + + + +Quando esegui il push delle modifiche sul repository del tuo progetto Astro, l'Action GitHub le distribuirà automaticamente per te al tuo URL GitHub. + +## Cambia il tuo URL GitHub in un dominio personalizzato + +Una volta che il tuo progetto Astro è [distribuito su GitHub pages in un URL GitHub](#come-distribuire) seguendo le istruzioni precedenti, puoi configurare un dominio personalizzato. Questo significa che gli utenti possono visitare il tuo sito al tuo dominio personalizzato `https://example.com` invece che `https://.github.io`. + + + +1. [Configura il DNS per il tuo fornitore di dominio](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#configuring-a-subdomain). +2. Aggiungi un record `./public/CNAME` al tuo progetto. + + Crea il file seguente nella tua cartella `public/` con una singola linea di testo che specifichi il tuo dominio personalizzato: + ```js title="public/CNAME" + sub.example.com + ``` + + Questo distribuirà il tuo sito al tuo dominio personalizzato invece che `user.github.io`. + +3. Nella tua configurazione Astro, aggiorna il valore di `site` con il tuo dominio personalizzato. Non impostare un valore per `base`, e rimuovilo se esiste: + + ```js title="astro.config.mjs" ins={4} del={5} + import { defineConfig } from 'astro/config' + + export default defineConfig({ + site: 'https://example.com', + base: '/my-repo' + }) + ``` + +4. Se necessario, aggiorna tutti i link interni di pagina per rimuovere il prefisso `base`: + + ```astro del="/my-repo" + About + ``` + + + +## Esempi + +- [Modello iniziale di Distribuzione di Github Pages](https://github.com/hkbertoson/github-pages) +- [Tema Starlight Flexoki (sito di produzione)](https://delucis.github.io/starlight-theme-flexoki/) +- [Campioni di Colore Espressivi per il Codice (sito di produzione)](https://delucis.github.io/expressive-code-color-chips/) +- [Blocchi Markdown Starlight (sito di produzione)](https://delucis.github.io/starlight-markdown-blocks/)