7

Install and Use Hugo On Ubuntu 18.04 / Debian 10

 3 years ago
source link: https://computingforgeeks.com/how-to-install-hugo-on-ubuntu-debian/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Install and Use Hugo On Ubuntu 18.04

In this guide, I’ll take you through the steps to install and use Hugo on Ubuntu 18.04 / Debian 10 Desktop and Server editions. Hugo has been confirmed to be the fastest open-source static site generator written in Go. Hugo is capable of generating a static site at a speed of <1 ms per page, the average site builds in less than a second. It ships with pre-made templates to make quick work of SEO, commenting, analytics and other functions.

Hugo supports unlimited content types, taxonomies, menus, dynamic API-driven content, and more, all without plugins. Additionally, you can output your content in multiple formats, including JSON or AMP

Install Hugo On Ubuntu 18.04 / Debian 10

Hugo can be installed on Ubuntu 18.04 / Debian 10 by downloading a .deb package or from apt repository.

Installing Hugo On Ubuntu 18.04 / Debian 10 from apt repository

Update your system apt index and install Hugo:

sudo apt update
sudo apt -y install hugo

You can confirm the location of hugo binary after installation using which

$ which hugo
/usr/bin/hugo

Installing Hugo On Ubuntu 18.04 / Debian 10 from .deb package

To install Hugo on Ubuntu 18.04 / Debian 10 from Debian package, first, download the latest release from Github releases page https://github.com/hugo/releases/. Select a version that matches your CPU architecture:

curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest \
 | grep  browser_download_url \
 | grep Linux-64bit.deb \
 | grep -v extended \
 | cut -d '"' -f 4 \
 | wget -i -

Then install the package using:

$ sudo dpkg -i hugo*_Linux-64bit.deb
 Selecting previously unselected package hugo.
 (Reading database … 187292 files and directories currently installed.)
 Preparing to unpack hugo_0.58.3_Linux-64bit.deb …
 Unpacking hugo (0.58.3) …
 Setting up hugo (0.58.3) …

If the installation was successful, you should be able to use hugo command:

$ hugo --help

Use Hugo on Ubuntu 18.04 / Debian 10 Linux

Now that Hugo is installed, you can start creating website content. Before that, you’ll need to create new content for your site. In this example, my site is called hugo.computingforgeeks.com

$ hugo new site hugo.computingforgeeks.com
Congratulations! Your new Hugo site is created in /home/jmutai/hugo.computingforgeeks.com.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme " command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new /.".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.

To create a test page, cd to site directory and use

$ hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>

Example:

$ cd hugo.computingforgeeks.com
$ ls
archetypes config.toml content data layouts static themes

Site content is placed inside content directory

$ hugo new posts/test-page.md
/home/jmutai/hugo.computingforgeeks.com/content/posts/test-page.md created

Add dummy content for test:

$ vim content/posts/test-page.md
---
title: "Test Page"
date: 2018-07-12T10:17:29Z
draft: true
---

# Hello World

This is my first hugo site, wooo!!

```
hugo_install="success"
if [[ $hugo_install == "success" ]]; then
  echo "Happy me"
```

bye!

Build site:

$ hugo

                   | EN  
+------------------+----+
  Pages            |  3  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 9 ms

This will create public folder and add content to it. To serve website using hugo build-in server, use:

$ hugo server

                   | EN  
+------------------+----+
  Pages            |  3  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 10 ms
Watching for changes in /root/hugo.computingforgeeks.com/{content,data,layouts,static}
Watching for config changes in /root/hugo.computingforgeeks.com/config.toml
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

For self hosting on a web server like Nginx or Apache, copy content inside public directory to your Web server document root.

Also check:

Install and Configure Drupal with Apache on CentOS 8

Install Drupal on Debian 10 (Buster) Linux

How to Install Jekyll on Ubuntu 18.04

How to Install and configure Ghost CMS on Ubuntu 16.04 / Debian 9


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK