Josh's Site

Back

Deployment

Deploy your site to various platforms

Local theme source#

The theme integration, components, plugins, types, and utilities are maintained directly in src/theme. No package linking or special environment variable is required.

The build command astro check && astro build validates and builds the project using that local source on every deployment platform.

Deployment Mode#

Vercel#

This theme supports Vercel by default:

  1. Push your code to your online Git repository (GitHub, GitLab, BitBucket).
  2. Import your project ↗ into Vercel.
  3. Vercel will automatically detect Astro and configure the right settings.
  4. Your application is deployed! (e.g. astro.vercel.app ↗)

And vercel also support static method:

astro.config.ts
import vercelServerless from '@astrojs/vercel/serverless'
import vercelStatic from '@astrojs/vercel/static'; 

export default defineConfig({
  //   ...
  adapter: vercelServerless() 
  adapter: vercelStatic(), 
})
ts

Node server#

If you are deploying with Node.js locally, you need to install @astrojs/node first:

bun add '@astrojs/node'
shell

Then follow the comments in astro.config.ts and modify like:

astro.config.ts
import node from '@astrojs/node'
import vercelServerless from '@astrojs/vercel/serverless'

export default defineConfig({
  //   ...
  adapter: vercelServerless(), 
  adapter: node({ mode: 'standalone' }), 

  integrations: [
    // prettier-ignore
    outputCopier({ 
      integ: ['sitemap', 'pagefind'] 
    }) 
  ]
})
ts

Bun server#

Bun also support static method.

Check @nurodev/astro-bun ↗ for more.

Static#

Remove all server adapter configuration in astro.config.ts:

astro.config.ts
import vercelServerless from '@astrojs/vercel/serverless'

export default defineConfig({
  //   ...
  adapter: vercelServerless(), 
  output: 'server'
})
ts

GitHub Pages#

See Astro: Configure Astro for GitHub Pages ↗.

For ones deploying on GitHub Pages with a base path, like username.github.io/repo-name, please read Deployment#Platform with Base Path. carefully.

Platform with Base Path#

  1. Set the base option in astro.config.ts to your base path, for example:

    astro.config.ts
    export default defineConfig({
      //   ...
      base: '/repo-name/' // Replace with your repository name
    })
    ts
  2. Update all internal links in Dynamic script files:

    • src/components/BaseHead.astro
    • src/pages/docs/DocsContent.astro
    • src/pages/rss.xml.ts
    • packages/pure/components/pages/PostPreview.astro (Customize Theme is required to make the change)
  3. Update all static resource paths:

    • Add base paths in src/site.config.ts. Especially the menu configs.
    • Add base paths in src/plugins/shiki-transformers.ts for all /icons/code.svg.
    • Add base paths in src/assets/styles/app.css for all url in @font-face property.