Creating a Hugo site on GitHub Pages Quick Backstory What is Hugo? Introduction & Necessary Installations Getting started with Hugo DEV's Worldwide Show and Tell Challenge Presented by Mux: Pitch Your Projects!
再次提醒,请接受所有提示,直到下载完成,Go 就会安装成功!如果您还不了解 Go,它是由 Google 开发的一种编程语言,如今越来越受欢迎。Hugo 将利用这种语言来创建网站框架。如果您想了解更多关于 Go 的信息,请点击这里(此处双关) 。
Hugo入门
如果您看到这里,说明您已安装以下软件:
自制啤酒
去
安装 Hugo
现在来说说 Hugo 的安装,正如你可能已经猜到的,Hugo 的安装与前两个安装步骤一样简单。只需输入以下命令:
brew install hugo
就这样!我们准备开始和雨果一起工作了!
为雨果做准备
让我们创建一个目录来存放所有工作。在终端中输入以下命令,进入你的主目录:
cd ~
然后,要创建名为“Sites”的目录,请键入:mkdir Sites
进入该目录cd Sites
现在您已进入站点目录,可以开始在这里使用 Hugo 了。 第一步非常简单,只需输入:
hugo new site yoursitename
`hugo new site` 命令将创建您网站的框架。执行该命令后,您应该会看到以下提示。
Congratulations! Your new Hugo site is created in /Users/YourName/Sites/yoursitename.
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.
现在,我发现让网站快速启动并运行的最简单方法是,将原目录中的文件exampleSite替换为您运行hugo new site sitename命令时创建的文件。换句话说,将原目录content中的所有文件移动exampleSite到您运行命令后创建的目录中content。yoursitename您需要对原目录中的所有文件执行此操作,exampleSite直到该目录完全为空。如果存在重复文件(例如config.toml文件),请删除命令创建的重复文件hugo new site。然后,将所有其他文件移出 coder 目录,即使它们没有对应的位置,也只需将它们从 coder 目录移到您的网站目录即可。以下文件无需移动:
baseurl = "http://examplesite" <- Change to http://yourgithubusername.github.io
title = "johndoe" <- Name your website here
theme = "hugo-coder"
languagecode = "en"
paginate = 20
canonifyurls = true
pygmentsstyle = "b2"
pygmentscodefences = true
pygmentscodefencesguesssyntax = true
disqusShortname = "yourdiscussshortname" <- Your short name for commenting
[params]
author = "John Doe" <- Your name
description = "John Doe's personal website" <- How you would describe the site
keywords = "blog,developer,personal"
info = "Full Stack DevOps and Magician" <- A small description of what your are
avatarurl = "images/avatar.jpg" <- your image
footercontent = "Enter a text here." <- a footer (quotes are nice)
hideCredits = false
hideCopyright = false
rtl = false
# Custom CSS
custom_css = []
[[params.social]]
name = "Github"
icon = "fab fa-github fa-2x"
weight = 1
url = "https://github.com/johndoe/" <- Change to your Github profile url
[[params.social]]
name = "Gitlab"
icon = "fab fa-gitlab fa-2x"
weight = 2
url = "https://gitlab.com/johndoe/" <- Change to your GitLab profile url
[[params.social]]
name = "Twitter"
icon = "fab fa-twitter fa-2x"
weight = 3
url = "https://twitter.com/johndoe/" <- Change to your twitter profile url
[[params.social]]
name = "LinkedIn"
icon = "fab fa-linkedin fa-2x"
weight = 4
url = "https://www.linkedin.com/in/johndoe/" <- Change to your Linkedin profile url
[[params.social]]
name = "Medium"
icon = "fab fa-medium fa-2x"
weight = 5
url = "https://medium.com/@johndoe" <- Change to your medium profile url
[[menu.main]]
name = "Blog"
weight = 1
url = "/posts/"
[[menu.main]]
name = "About"
weight = 2
url = "/about/"
[[menu.main]]
name = "Projects"
weight = 3
url = "/projects/"
[[menu.main]]
name = "Contact me"
weight = 5
url = "/contact/"
[languages]
[languages.en]
languagename = "English" # The language name to be displayed in the selector.
title = "John Doe"
# You can configure the theme parameter for each language.
[languages.en.params]
author = "John Doe" <- Your name
info = "Full Stack DevOps and Magician" <- What you do
description = "John Doe's personal website" <- quick description
keywords = "blog,developer,personal"
[languages.en.menu] # It is possible to change the menu too.
[[languages.en.menu.main]]
name = "About"
weight = 1.0
url = "/about/"
[[languages.en.menu.main]]
name = "Blog"
weight = 2.0
url = "/posts/"
[[languages.en.menu.main]]
name = "Projects"
weight = 3
url = "/projects/"
[[languages.en.menu.main]]
name = "Contact me"
weight = 5
url = "/contact/"
------------------------delete below (unless you know polish) ----------------
[languages.pl]
languagename = "Polski"
title = "John Doe po polsku"
[languages.pl.params]
author = "John Doe"
description = "Strona domowa John'a Doe"
keywords = "blog,developer,strona domowa"
info = "Full Stack DevOps i Magik"
[languages.pl.menu]
[[languages.pl.menu.main]]
name = "O mnie"
weight = 1.0
url = "/pl/about/"
[[languages.pl.menu.main]]
name = "Blog"
weight = 2.0
url = "/pl/posts/"
[[languages.pl.menu.main]]
name = "projektowanie"
weight = 3
url = "/projektowanie/"
[[languages.pl.menu.main]]
name = "kontakt"
weight = 5
url = "/kontakt/"
-------------------------------------------------------------------
现在你已经拥有了一个很棒的网站,打开about.md文件,写上你的个人简介,然后在“关于我”页面刷新浏览器。你应该会看到网站在浏览器中自动更新!这对于测试文章原型非常方便!稍微摆弄一下这些文件,开始了解目录结构以及它们在浏览器中的显示方式。理解布局将使你以后使用 Hugo 更加直观。
创建新内容的基础知识
在 Hugo 站点中创建新文件非常简单。首先,创建新内容时,您始终需要位于您的yoursitename目录下,然后始终使用相应的hugo new (contentpathhere)命令。尝试使用以下命令创建新文章。
hugo new posts/firstpost.md
找到 firstpost.md 文件并进行编辑,确保draft将 header 中的设置更改为 而false不是true。保存该文件,然后在浏览器中刷新页面,接着访问博客,搞定!你的第一篇文章就创建成功了!这就是在 Hugo 网站上创建新文章的基本流程。当你更熟悉 Hugo 的基础知识后,可以阅读更多关于创建新内容的内容!