Deployment
Deploy your site to various platforms
Package Mode#
This theme which >= v4.0.0 has integrated NPM package mode. Recommended way is remove local package file, and install the theme integration from NPM. If there’s some reason you want to change the package content, you should link local package to your theme template. A bun
method is integrated. You should:
- Add environment variable
BUN_LINK_PKG=true
. - Run
bun pure check
to link the package automatically.
This method can also work on Deployment for other platforms like ‘Vercel’. All you need is to add the environment variable to build options on your platform control settings. The build command astro-pure check && astro check && astro build
will automatically link the package.
Deployment Mode#
Vercel#
This theme supports Vercel by default:
- Push your code to your online Git repository (GitHub, GitLab, BitBucket).
- Import your project ↗ into Vercel.
- Vercel will automatically detect Astro and configure the right settings.
- Your application is deployed! (e.g. astro.vercel.app ↗)
And vercel also support static method:
import vercelServerless from '@astrojs/vercel/serverless'
import vercelStatic from '@astrojs/vercel/static';
export default defineConfig({
// ...
adapter: vercelServerless()
adapter: vercelStatic(),
})
tsNode server#
If you are deploying with Node.js locally, you need to install @astrojs/node
first:
bun add '@astrojs/node'
shellThen follow the comments in astro.config.ts
and modify like:
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']
})
]
})
tsBun server#
Bun also support static method.
Check @nurodev/astro-bun ↗ for more.
Static#
Remove all server adapter configuration in astro.config.ts
:
import vercelServerless from '@astrojs/vercel/serverless'
export default defineConfig({
// ...
adapter: vercelServerless(),
output: 'server'
})
tsGitHub 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#
-
Set the
base
option inastro.config.ts
to your base path, for example:astro.config.ts
tsexport default defineConfig({ // ... base: '/repo-name/' // Replace with your repository name })
-
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)
-
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.
- Add base paths in