Vercel allows deployment by importing a Git repository from GitHub, GitLab, BitBucket or third-party platforms.
Deploy on Vercel
After signing up and logging into Vercel:
- Choose your Git provider and install the corresponding integration if prompted.
- Select your site’s repository and click Import.
On the New Project page:
- Project Name — This will be part of your deployment URL:
https://[project-name].vercel.app
Attention
[project-name] is not available, Vercel will assign a random URL like https://[random-name].vercel.app to your project.Framework Preset: Select Hugo.
In the Build and Output Settings section click the edit icon and set as Build Command:
- With search:
hugo --gc --minify && npx pagefind --site "public"- Without search:
hugo --gc --minifyIn the Environment Variables add:
- Key:
HUGO_VERSION— Value:0.148.0
Note: Use aHUGO_VERSIONgreater than0.146.1, ideally matching your local version.
- Key:
Click Deploy.
Once the deployment is complete:
- Go to your Project dashboard and click Domains.
- If the default production domain matches your project name (
[project-name].vercel.app), update your root hugo.toml:
baseURL = "https://[project-name].vercel.app"
- Commit and push the change to the Git Provider.
If it doesn’t match and you want a specific name:
- Click Add Domain.
- Enter a custom subdomain:
[custom-name].vercel.app. - Click Add Domain and then Save.
- After your preferred domain is added successfully:
- Delete the old domain you no longer need by clicking the three dots.
- Update the
baseURLin yourhugo.tomlto reflect the new domain. - Push the change to the Git provider.
Tip
Vercel Json (Optional)
Vercel settings can be configured not only through the Vercel dashboard but also with a vercel.json file placed at the root of your project.
Alpha includes a vercel.json file located at: themes/alpha/vercel.json. The provided configuration includes security headers and a Content Security Policy (CSP) identical to those in the themes/alpha/static/_headers file.
Refer to the official Vercel JSON documentation for full syntax and available options.
vercel.json
vercel.json does not contain comments.How to use:
- Copy the file from
themes/alpha/vercel.jsonto your site’s root directory (notstatic/, but the actual root of your project). - Review and customize the rules to match your site’s security and performance needs.