部署你的 Astro 站点进行渲染
你可以将 Astro 项目部署到 使成为,这是一项使用免费 TLS 证书、全球 CDN、DDoS 保护、专用网络和自动部署功能构建网站的服务。
¥You can deploy your Astro project to Render, a service to build websites with free TLS certificates, a global CDN, DDoS protection, private networks, and auto deploys from Git.
¥How to deploy
-
Create a render.com account and sign in
-
Click the New + button from your dashboard and select Static Site
-
Connect your GitHub or GitLab repository or alternatively enter the public URL of a public repository
-
Give your website a name, select the branch and specify the build command and publish directory
- build command:
npm run build
- publish directory:
dist
, for static sites;dist/client
if you’re usingserver
orhybrid
server-rendering modes. - Environment variables (advanced): By default, Render uses Node.js 14.17.0, but Astro requires a higher version. Add an environment variable with a Variable key of
NODE_VERSION
and a Value ofv18.17.1
orv20.3.0
or higher to tell Render to use a compatible Node.js version. Alternatively, add a.node-version
or.nvmrc
file to your project to specify a Node.js version.
- build command:
-
Click the Create Static Site button