What's Hugo?
Hugo is a website building framework. What does that mean though? It means you can focus on content, and let hugo wrap your words in elegant code.
Get Hugo:
- Using a web browser, navigate to Hugo's website. https://gohugo.io/
- Navigate to
Getting Started -> Install Hugo -> Binary (Cross Platform)
or follow the link here: https://gohugo.io/getting-started/installing/ - The downloads are housed on the Hugo github repository.
- In our example here, we will use the Windows archive, but they are all very similar. Download the variation specific to your operation system.
- Once downloaded, unpack the archive in a convient place. For Windows I am generating a
C:\Hugo\bin
directory.
Optional: Add the Hugo Folder to the Windows Path Variable
This configuration change is handy for commonly used commands. With this change in place you can run hugo
rather than C:\Hugo\bin\hugo.exe
.
- Click the Search Windows icon.
- Type "This PC"
- Right click on This PC from the search results and select Properties.
- Select Advanced System Properties from the left menu.
- Select Environment Variables... from just above the cancel button.
- Select the Path User variable from the top panel, and click Edit....
- Select New and type your path
C:\Hugo\bin
in the text area. - Select OK and exit out of the settings windows.
- Start a new command prompt with
cmd
to see the change.
Configure Hugo
Install a new site in your working directory
- Open a new command prompt with
cmd
and change the working directory.C:\> cd C:\Hugo
- Generate a new site tree.
C:\> hugo new site myhobbiest Congratulations! Your new Hugo site is created in C:\Hugo\myhobbiest. 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 <THEMENAME>" command. 2. Perhaps you want to add some content. You can add single files with "hugo new <SECTIONNAME>\<FILENAME>.<FORMAT>". 3. Start the built-in live server via "hugo server". Visit https://gohugo.io/ for quickstart guide and full documentation.
- Examine the new site.
C:\Hugo>cd myhobbiest C:\Hugo\myhobbiest>dir Volume in drive C is Windows Volume Serial Number is 5A0C-A11C Directory of C:\Hugo\myhobbiest 11/24/2020 08:31 AM <DIR> . 11/24/2020 08:31 AM <DIR> .. 11/24/2020 08:31 AM <DIR> archetypes 11/24/2020 08:31 AM 82 config.toml 11/24/2020 08:31 AM <DIR> content 11/24/2020 08:31 AM <DIR> data 11/24/2020 08:31 AM <DIR> layouts 11/24/2020 08:31 AM <DIR> static 11/24/2020 08:31 AM <DIR> themes 1 File(s) 82 bytes 8 Dir(s) 22,856,654,848 bytes free C:\Hugo\myhobbiest>
Install a Hugo theme
- Many themes are available in the Hugo theme library, but in this example we will use Axiom.
- Open the Axiom theme page at https://themes.gohugo.io/axiom/.
- Click Download.
- You will be redirected to the github project. From there select the code download button.
- Select Download ZIP.
- Open the zip file.
- Select Extract and then select Extract All from the expanded panel.
- Navigate to
C:\Hugo\myhobbiest\themes
. - Click on Select Folder.
- Click on Extract.
Define the website
- Open
config.toml
in notepad fromC:\Hugo\myhobbiest
.C:\Hugo\myhobbiest> notepad config.toml
- Load a default configuration and edit as necessary.
baseURL = "https://myhobbiest.com" title = "My Hobbies Blog" languageCode = "en-us" defaultContentLanguage = "en" theme = "axiom-master" paginate = 4 canonifyURLs = false summaryLength = 40 rssLimit = 100 enableEmoji = true enableRobotsTXT = true pluralizelisttitles = false [permalinks] posts = "/:filename" [params] mainSections = ["posts"] copyrightYear = 2020 # Go Reference time: Mon Jan 2 15:04:05 MST 2006 dateFormat = "Jan 2, 2006 3:04PM" highlight = "dark" [params.brand] domain = "myhobbiest.com" email = "info AT myhobbiest DOT com" [params.social] #facebook = "https://www.facebook.com/user_or_page" #github = "https://github.com/user" #instagram = "https://instagram.com/user" #linkedin = "https://www.linkedin.com/in/user" #pinterest = "https://www.pinterest.com/user" #stackoverflow = "https://stackoverflow.com/users/user" twitter = "https://twitter.com/myhobbiest" rss = "https://www.myhobbiest.com/feed.atom" #youtube = "https://www.youtube.com/user" #footer = ["twitter", "rss"] [params.services] #googleAnalyticsId = "UA-901234567-8" #googleTagManagerId = "" #googleAdsId = "" #googleAdsenseId = "" ##googleAdsenseAdSlotId = "" #googleAdsenseLoad = "" #googleAdsConversionId = "" #googleAdsConversionValue = 0 #facebookApp = "" #facebookPixel = "" #disqusShortname = "" #[params.logo] #inline = true #path = "image/brand/logo.svg" [params.image] width = "2048" height = "1024" faviconIco = "favicon.ico" faviconAlt = "image/brand/favicon.png" icon1To1 = "image/brand/icon-1-1.png" icon2To1 = "image/brand/icon-2-1.png" default = "image/posts/begin.jpg" [params.font] type = "" path = "" files = [] [params.cdn] provider = "local" type = "image" [params.cloudinary] #host = "https://res.cloudinary.com/CLOUD_NAME/" #version = "" #image = "image/upload/" #raw = "raw/upload/" #video = "video/upload/" [params.cloudinary.presets] #base = "f_auto,q_auto/" #page = "w_auto,dpr_auto,c_scale,f_auto,q_auto/" #feature = "w_auto,dpr_auto,c_scale,f_auto,q_auto/" #summary = "w_auto,dpr_auto,c_scale,f_auto,q_auto/" [outputs] home = ["HTML", "ATOM"] section = ["HTML"] taxonomy = ["HTML"] taxonomyTerm = ["HTML"] [outputFormats] [outputFormats.ATOM] name = "ATOM" baseName = "feed" mediaType = "application/atom+xml" [mediaTypes] [mediaTypes."application/atom+xml"] suffixes = ["atom"] [markup] [markup.goldmark] [markup.goldmark.extensions] definitionList = false footnote = true linkify = false strikethrough = false table = true taskList = false typographer = false [markup.goldmark.renderer] unsafe = true [markup.goldmark.parser] attribute = false [markup.highlight] codeFences = true noClasses = false tabWidth = 2 # lineNos = true # lineNumbersInTable = false [menu] [[menu.main]] url = "/posts/" name = "Posts" weight = 1 [[menu.foot]] url = "/posts/" name = "Posts" weight = 1 [[menu.foot]] url = "/about/" name = "About" weight = 2 [[menu.foot]] url = "/contact/" name = "Contact" weight = 3 [[menu.foot]] url = "/privacy/" name = "Privacy" weight = 4 [languages] [languages."en"] weight = 1 languageName = "English"
- Verify the site is functional.
C:\Hugo\myhobbiest> hugo server Building sites … WARNING: calling IsSet with unsupported type "invalid" (<nil>) will always return false. | EN -------------------+----- Pages | 6 Paginator pages | 0 Non-page files | 0 Static files | 0 Processed images | 0 Aliases | 0 Sitemaps | 1 Cleaned | 0 Built in 25 ms Watching for changes in C:\Hugo\myhobbiest\{archetypes,content,data,layouts,static,themes} Watching for config changes in C:\Hugo\myhobbiest\config.toml Environment: "development" 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
- In your web browser, navigate to http://localhost:1313/ and you should see a bare, but functional website.
Conclusion
Now you have a website, but there's still a lot of configuration to do before it's ready to be hosted. I'll cover those tasks in detail in a future post.