TB-0002Rev. 1

Deploy Astro from GitHub to Hostinger with the right settings

Connect a GitHub repo to Hostinger, pick the Astro preset, build to dist, and redeploy on every push to main. Includes the setup mistakes we hit.

Document details
Author
Published
Revision
Rev. 1
Read
6 min read
Language
EnglishRead in Vietnamese
Share

To deploy a static Astro blog to Hostinger, import your GitHub repo in hPanel, pick the Astro preset, and use npm with the build command npm run build and the output folder dist. After the first deploy, every push to main makes Hostinger build and deploy again. Two problems almost broke the first deploy of this blog: an Astro release that needed a newer Node, and build settings that Hostinger guessed wrong. The fixes for both are below.

Short version

  • Pin an Astro version that runs on both your local Node and the Node version Hostinger runs. Astro 7.4.14 needs Node 22.23.4 or later, so this blog uses Astro 7.3.8.
  • Set site in astro.config.mjs to get a correct sitemap and canonical URLs.
  • On Hostinger: preset Astro, Node 22.x, package manager npm, build npm run build, output dist, no entry file.
  • Do not let Hostinger build before the repo has Astro code. It guesses the wrong build command.
  • Do not commit large .mp4 files. GitHub blocks files over 100 MiB.

Check what you need before you deploy

You need three things:

  1. A GitHub repo with an Astro project that builds on your machine.
  2. A Hostinger plan that runs Node.js apps. The Hostinger guide to adding a front-end website says Node.js apps are available on all web hosting and Cloud hosting plans. Confirm your plan in hPanel, because the Astro deploy guide for Hostinger still lists an older requirement.
  3. Node.js 22 on your machine. Hostinger supports Node 18.x, 20.x, 22.x, and 24.x, according to the Hostinger Node.js docs.

Pin an Astro version that matches Node

The first failure showed up on our own machine, before we opened Hostinger. The latest Astro release when we wrote this was 7.4.14, and npm run build stopped at once:

Node.js v22.20.0 is not supported by Astro!
Please upgrade Node.js to a supported version: ">=22.23.4"

Our machine runs Node 22.20. The 22.x option on Hostinger does not say which patch release it uses, so we could not be sure it meets 22.23.4. We first pinned Astro 6.4.8. Then npm audit reported cross-site scripting advisories for that version, with the fix in Astro 7.3.8. So we moved to 7.3.8, the newest release that still runs on Node 22.12.

Check the Node requirement of a version before you install it:

npm view astro@7.3.8 engines.node

The command prints >=22.12.0. Install Astro 7.3.8 and the integrations that match it:

npm install astro@7.3.8 @astrojs/mdx@8.0.3 @astrojs/sitemap@3.7.7 @astrojs/rss@4.0.20
npm audit

Run npm audit after every version change. A pin that avoids a Node error can still leave a known security hole in place.

Then state the Node requirement in package.json, so anyone who clones the repo sees it:

{
  "engines": { "node": ">=22.12.0" },
  "scripts": {
    "dev": "astro dev",
    "build": "astro build",
    "preview": "astro preview"
  }
}

Set the site URL and language routes in astro.config.mjs

Astro builds a static site by default and writes it to dist/, according to the Astro configuration reference. The same page says Astro uses the site value to generate your sitemap and canonical URLs. Without site, the @astrojs/sitemap integration logs a warning and skips the sitemap.

This blog has two languages, so it also sets i18n. With prefixDefaultLocale: true, every URL has a language prefix, including Vietnamese, the default language. The Astro internationalization guide covers the options.

// astro.config.mjs
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';

export default defineConfig({
  site: 'https://tech-blog.io',
  integrations: [mdx(), sitemap()],
  i18n: {
    defaultLocale: 'vi',
    locales: ['vi', 'en'],
    routing: { prefixDefaultLocale: true },
  },
});

Build on your machine before you open Hostinger:

npm run build
ls dist

You should see index.html, the vi/ and en/ folders, and sitemap-index.xml. If this command fails on your machine, it fails on Hostinger too.

Connect the GitHub repo in hPanel

The Hostinger Node.js deploy guide lists these steps:

  1. In hPanel, add a new website and choose Import Git repository.
  2. Choose GitHub and authorize Hostinger the first time.
  3. Select your repo, then click Next.

Hostinger then opens a screen where you review the build settings, with a label that says it detected the framework.

Fill in the build settings for Astro

These are the settings we use for this blog:

Setting Value
Framework preset Astro
Branch main
Node version 22.x
Runtime Node.js
Root directory ./
Package manager npm
Build command npm run build
Output directory dist
Entry file leave empty

Hostinger's docs list these fields but do not give values for Astro. The values above come from our package.json and from the dist folder that Astro creates. If the preset fills in something else, change it to match your project.

A static Astro site needs no adapter. Add @astrojs/node only when some pages render on the server.

Push to main to deploy

Hostinger builds for the first time when you click deploy. After that, every push to the selected branch starts a new build and deploy, according to the Hostinger Node.js deploy guide. The front-end website guide says you can turn off automatic deploys in the dashboard if you want to review first.

git add .
git commit -m "Add a new post"
git push origin main

A push to main goes to production, so run npm run build on your machine before each push.

Keep large videos out of the repo

This blog has .mp4 videos that we record ourselves. Git warns about files over 50 MiB, and GitHub blocks files over 100 MiB, according to GitHub's docs on large files. Large files also make the repo heavier for every clone.

This blog follows two rules:

  • Short clips under 20 MB go in public/videos/.
  • Long videos go to a video CDN, and the post embeds them by URL.

Compress a video before you publish it. The -movflags +faststart option moves the index (the moov atom) to the start of the file, so the browser can play the video before the download finishes. The option is described in the FFmpeg formats documentation.

ffmpeg -i input.mp4 -c:v libx264 -crf 26 -preset slow -c:a aac -b:a 128k -movflags +faststart output.mp4

On the page, the <video> tag uses preload="none" to tell the browser not to preload the video before the reader presses play, and playsinline so phones play it inside the page. The MDN page on the video element describes both attributes.

Fix the common failures

Symptom Cause Fix
Build stops with "Node.js ... is not supported by Astro" The Astro version needs a newer Node than the one running Pin an Astro version that supports Node 22, or pick Node 24.x on Hostinger
Build says there is no build script The repo has no Astro code yet Push the Astro code first
The deploy starts a server or looks for index.js The build command is yarn run start, or an entry file is set Set the build command to npm run build and clear the entry file
Blank page or 404 after deploy Wrong output directory Set the output directory to dist
No sitemap-index.xml in dist site is missing from astro.config.mjs Add site with your real domain
git push is rejected for a large file An .mp4 over 100 MiB is in a commit Remove the file from the commit and host the video on a CDN

Revision history

DateRevision history
2026-12-04First release