Quick start | Hugo

Quick start

You must also be comfortable working from the command line.

Create a site Commands

If you are a Windows user:

  • Do not use the Command Prompt
  • Do not use Windows PowerShell
  • Run these commands from PowerShell or a Linux terminal such as WSL or Git Bash

PowerShell and Windows PowerShell are different applications.

Run these commands to create a Hugo site with the Ananke theme. The next section provides an explanation of each command.

> hugo.toml 

View your site at the URL displayed in your terminal. Press Ctrl + C to stop Hugo’s development server.

Explanation of commands

Create the directory structure for your project in the quickstart directory.

Change the current directory to the root of your project.

Initialize an empty Git repository in the current directory.

Clone the Ananke theme into the themes directory, adding it to your project as a Git submodule.

Append a line to the site configuration file, indicating the current theme.

> hugo.toml 

Start Hugo’s development server to view the site.

Press Ctrl + C to stop Hugo’s development server.

Add content

Add a new page to your site.

Hugo created the file in the content/posts directory. Open the file with your editor.

Notice the draft value in the front matter is true . By default, Hugo does not publish draft content when you build the site. Learn more about draft, future, and expired content.

Add some markdown to the body of the post, but do not change the draft value.

Save the file, then start Hugo’s development server to view the site. You can run either of the following commands to include draft content.

View your site at the URL displayed in your terminal. Keep the development server running as you continue to add and change content.

Hugo’s rendering engine conforms to the CommonMark specification for markdown. The CommonMark organization provides a useful live testing tool powered by the reference implementation.

Configure the site

With your editor, open the site configuration file ( hugo.toml ) in the root of your project.

Make the following changes:

  1. Set the baseURL for your production site. This value must begin with the protocol and end with a slash, as shown above.
  2. Set the languageCode to your language and region.
  3. Set the title for your production site.

Start Hugo’s development server to see your changes, remembering to include draft content.

Most theme authors provide configuration guidelines and options. Make sure to visit your theme’s repository or documentation site for details.

The New Dynamic, authors of the Ananke theme, provide documentation for configuration and usage. They also provide a demonstration site.

Publish the site

In this step you will publish your site, but you will not deploy it.

When you publish your site, Hugo creates the entire static site in the public directory in the root of your project. This includes the HTML files, and assets such as images, CSS files, and JavaScript files.

When you publish your site, you typically do not want to include draft, future, or expired content. The command is simple.

To learn how to deploy your site, see the hosting and deployment section.
Ask for help

Hugo’s forum is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about requesting help before asking your first question.

Other resources

For other resources to help you learn Hugo, including books and video tutorials, see the external learning resources page.

See also

  • BSD
  • Basic usage
  • External learning resources
  • GitInfo
  • Host on 21YunBox
"

Скачать книгу «Quick start | Hugo» fb2

Коментарии