How to

#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:

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

  1. Set up baseURL in your config.toml file:
baseURL = "https://how2gpt.netlify.app/"
  1. Push your code to GitHub:

    • Create a new repository on GitHub and name it how2gpt.xyz.
    • Initialize the local repository and push the code:
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
  1. 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 to public/.
    • 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.