I recently decided to migrate my Hugo website from Netlify to Vercel to take advantage of Vercel’s features.
After cloning the project and removing any Netlify-specific configurations, I attempted to deploy the site on Vercel.
However, I encountered deployment errors because Vercel was using a different Hugo version than my local environment.
My local Hugo version was:
hugo v0.125.7-b1d808bc373f53ad37c8966bb02a6aea095db5f8 windows/amd64 BuildDate=2024-05-08T14:46:24Z VendorInfo=gohugoio
To resolve this issue, I created a vercel.json
file at the root of my project in Visual Studio Code (VSCode) with the following content:
{
"build": {
"env": {
"HUGO_VERSION": "0.125.7"
}
}
}
This configuration explicitly sets the Hugo version that Vercel should use during the build process. After adding this file and redeploying,
Vercel utilized the specified Hugo version, aligning with my local development environment and resolving the deployment issues.
By ensuring that both my local and Vercel environments use the same Hugo version, I was able to successfully migrate my website without further issues.