#hugo #hugo #netlify #netlify #sitio web #website #deployment #despliegue
Creating a website with Hugo and deploying it to Netlify involves a series of steps. Here’s a concise guide on how to set this up, assuming you already have a basic understanding of how to use your terminal and Git.
Check also:
- How to Host Obsidian Notes on Netlify using Hugo with SEO template - Second Edition
- How to Specify a Hugo Version for Netlify Deployment
1: Install Hugo
First, you need to install Hugo on your system. Since you’re using macOS, you can install Hugo via Homebrew:
Mac:
brew install hugo
hugo version
Windows:
choco install hugo -confirm
hugo version
Linux:
snap install hugo --channel=extended
hugo version
2: Create a New Hugo Site
Create a new site using Hugo:
hugo new site how2gpt.xyz
cd how2gpt.xyz
3: Add a Theme
Add a theme from the Hugo themes directory. For example, to add the “Hugo SEO Theme” theme:
git init git submodule add https://github.com/vvmspace/hugo-seo-theme.git vvmspace/hugo-seo-theme
echo 'theme = "hugo-seo-theme"' >> config.toml
4: Add Some Content
hugo new posts/my-first-post.md
Edit content/posts/my-first-post.md
in your text editor and add some content.
How to start writing in Markdown
5: Run Hugo Locally
Start the Hugo server with:
hugo server
Visit http://localhost:1313
to see your new website.
6: Prepare for Deployment
Make sure your website’s content is ready for deployment. Stop the server (Ctrl + C), and run:
hugo
This command builds your static site into the public/
directory.
7: Deploy to Netlify
- Set up
baseURL
in yourconfig.toml
file:
baseURL = "https://how2gpt.netlify.app/"
-
Push your code to GitHub:
- Create a new repository on GitHub and name it
how2gpt.xyz
. - Initialize the local repository and push the code:
- Create a new repository on GitHub and name it
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourusername/how2gpt.xyz.git
git push -u origin main
-
Set up Netlify:
- Go to Netlify and sign in.
- Click “New site from Git” and select GitHub.
- Choose the repository you just pushed.
- Set the build command to
hugo
and the publish directory topublic/
. - Click “Deploy site”.
Netlify will automatically deploy your site and provide you with a URL to access it. You can also set up a custom domain in Netlify’s domain management settings to use how2gpt.xyz
.