<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sassi Med</title>
    <description>The latest articles on DEV Community by Sassi Med (@xifm0).</description>
    <link>https://dev.to/xifm0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1974632%2F24e1b7e2-3359-42bd-9116-06a25988193a.jpg</url>
      <title>DEV Community: Sassi Med</title>
      <link>https://dev.to/xifm0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xifm0"/>
    <language>en</language>
    <item>
      <title>Step-by-Step Guide to Deploy Hugo on Vercel</title>
      <dc:creator>Sassi Med</dc:creator>
      <pubDate>Sun, 06 Oct 2024 16:18:38 +0000</pubDate>
      <link>https://dev.to/xifm0/step-by-step-guide-to-deploy-hugo-on-vercel-57jb</link>
      <guid>https://dev.to/xifm0/step-by-step-guide-to-deploy-hugo-on-vercel-57jb</guid>
      <description>&lt;p&gt;&lt;strong&gt;This guide will walk you through deploying a Hugo website to Vercel. &lt;br&gt;
I will ensure you avoid at least one common mistake.&lt;/strong&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Create Your Hugo Site Locally
&lt;/h2&gt;

&lt;p&gt;Assuming Hugo is already installed:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hugo new site &amp;lt;my-hugo-site&amp;gt;&lt;/code&gt; &lt;/p&gt;


&lt;h2&gt;
  
  
  2. Push Your Hugo Site to GitHub
&lt;/h2&gt;

&lt;p&gt;Then set up a git repository for the site.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add commit and push your project files:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;br&gt;
git commit&lt;br&gt;
git push -u origin master&lt;/code&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  3.Add a theme for your Hugo site.
&lt;/h2&gt;

&lt;p&gt;For instance, you can use a Nno jQuery, no Bootstrap super fast theme like &lt;a href="https://github.com/hugo-sid/hugo-blog-awesome" rel="noopener noreferrer"&gt;hugo-blog-awesome&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;As a github module:&lt;br&gt;
&lt;code&gt;git submodule add https://github.com/hugo-sid/hugo-blog-awesome.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or a Hugo module&lt;br&gt;
&lt;code&gt;hugo mod get github.com/hugo-sid/hugo-blog-awesome&lt;/code&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  4. Add vercel configuration (vercel.json)
&lt;/h2&gt;

&lt;p&gt;In root dir add vercel.json where we gonna define hugo version Go version and the buildCommand, after defining hugo as Framework Preset in vercel those config will be auto detected.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;a&gt;vercel.json&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "build": {
    "env": {
      "HUGO_VERSION": "0.135.0",
      "GO_VERSION": "1.19.5"
    }
  },
 "buildCommand": "hugo --gc --minify"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;- use&lt;/em&gt; &lt;code&gt;hugo env&lt;/code&gt; &lt;em&gt;to show versions of Go and Hugo you're using&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then push update to Github:&lt;br&gt;
&lt;code&gt;git add .&lt;br&gt;
git commit -m "vercel deploy"&lt;br&gt;
git push -u origin master&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  5 . Deploy Your Site on Vercel
&lt;/h2&gt;

&lt;p&gt;During the import process, ensure that the project is connected correctly to your Hugo repository.&lt;/p&gt;

&lt;p&gt;Vercel detect env and command build:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsmdpzbyrkgomhsgqki4s.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsmdpzbyrkgomhsgqki4s.jpg" alt="vercel pre build" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or you ou can set it manually in Vercel environment variables here&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fveolvq2z0nd2mofyxmei.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fveolvq2z0nd2mofyxmei.jpg" alt="Vercel set env" width="800" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Deployement logs:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4y808ll4mp33f34qst4g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4y808ll4mp33f34qst4g.jpg" alt="deploy logs" width="800" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81xyhdgsyehfbbcn8a7r.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81xyhdgsyehfbbcn8a7r.gif" alt="Fast deploy" width="320" height="320"&gt;&lt;/a&gt;&lt;br&gt;
After a successful build 🎉🎉, Vercel will provide a preview link where you can view your live Hugo website. You can also configure a custom domain through Vercel's settings for your project.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwjh5s194k7452xns1pw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwjh5s194k7452xns1pw.jpg" alt="Vercel deploy ok" width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Add a Domain
&lt;/h2&gt;

&lt;p&gt;If you have a domain name you can add the domain name to the vercel in domains section of the project settings. Then add a CNAME to your domain provider to point to the vercel domain.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ &lt;em&gt;Fix Common Deployment Issues&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The main problem is that hugo support is not that good even if vercel already updated their Node image to have Hugo and with default settings, I met with the error of hugo layout not found and my deployment leads to an XML page. &lt;br&gt;
This is because the env parameter Hugo and Go versions need to be defined  with in the json file vercel.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Setting up a personal site with Hugo and Vercel is really easy, despite some minor problems. I hope this post can help you to set up your own site. For more details about the changes I made to the site, see the &lt;a href="https://github.com/m0hss/m0fix-blog/commits/master/" rel="noopener noreferrer"&gt;commit history&lt;/a&gt; of &lt;a href="https://tn.m0fix.me/" rel="noopener noreferrer"&gt;my site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2oj35526g1vv8fuftaor.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2oj35526g1vv8fuftaor.gif" alt="NEGAN GIF" width="540" height="340"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Some Sources:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://vercel.com/guides/deploying-hugo-with-vercel" rel="noopener noreferrer"&gt;https://vercel.com/guides/deploying-hugo-with-vercel&lt;/a&gt;&lt;br&gt;
&lt;a href="https://vercel.com/docs/projects/project-configuration" rel="noopener noreferrer"&gt;https://vercel.com/docs/projects/project-configuration&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.gusibi.site/article/Best-Practices-for-Deploying-Hugo-on-Vercel" rel="noopener noreferrer"&gt;https://blog.gusibi.site/article/Best-Practices-for-Deploying-Hugo-on-Vercel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hugo</category>
      <category>go</category>
      <category>vercel</category>
      <category>github</category>
    </item>
  </channel>
</rss>
