hongtaoh / hongtaoh.github.io

Hongtao Hao's homepage
https://hongtaoh.com
MIT License
18 stars 9 forks source link

cn/2021/03/02/personal-website-tutorial/ #10

Closed utterances-bot closed 7 months ago

utterances-bot commented 2 years ago

郝鸿涛:Hongtao Hao

https://hongtaoh.com/cn/2021/03/02/personal-website-tutorial/

yuzhao66 commented 1 year ago

博主你好!请问在网站主题的最后一步出现这个问题是为什么呀,应该如何修改~ $ hugo server -D Start building sites … hugo v0.112.3-ba6f74e40420d76f15fc8c2358be90f7aca98e0e windows/amd64 BuildDate=2023-05-24T14:42:50Z VendorInfo=gohugoio Built in 121 ms Error: error building site: assemble: "D:\quickstart\content\en\about_index.md:5:1": failed to extract shortcode: template for shortcode "block" not found

hongtaoh commented 1 year ago

@zoeyyuzhao 我的猜测是 config.toml 种的 theme 你用的不是 hugo-ht 这个主题,但没看到你的代码我没办法确定。

yuzhao66 commented 1 year ago

谢谢博主,我是按照教程一步步来的,就是修改了个人路径放在了d盘。这个是做的过程中的代码,可以帮忙看一下吗?我反复重新做了好几遍都是这个样子,不知道为什么 13599@xiaonongnv MINGW64 ~ $ cd /d/

13599@xiaonongnv MINGW64 /d $ hugo new site quickstart Congratulations! Your new Hugo site is created in D:\quickstart.

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.

13599@xiaonongnv MINGW64 /d $ cd quickstart/themes git clone https://github.com/hongtaoh/hugo-ht mkdir hugo-ht-new # create a new folder called hugo-ht-new cp -r hugo-ht/ hugo-ht-new # copy everything in hugo-ht to hugo-ht-new rm -rf hugo-ht # delete the folder of hugo-ht mv hugo-ht-new hugo-ht # change folder name cd .. cp -r themes/hugo-ht/exampleSite/ . # copy everything in the exampleSite folder to quickstart cp -r themes/hugo-ht/archetypes . # replace the archetypes folder Cloning into 'hugo-ht'... remote: Enumerating objects: 276, done. remote: Counting objects: 100% (276/276), done. remote: Compressing objects: 100% (177/177), done. remote: Total 276 (delta 124), reused 235 (delta 83), pack-reused 0 Receiving objects: 100% (276/276), 304.88 KiB | 907.00 KiB/s, done. Resolving deltas: 100% (124/124), done.

13599@xiaonongnv MINGW64 /d/quickstart $

13599@xiaonongnv MINGW64 /d/quickstart $ hugo server -D Start building sites … hugo v0.112.3-ba6f74e40420d76f15fc8c2358be90f7aca98e0e windows/amd64 BuildDate=2023-05-24T14:42:50Z VendorInfo=gohugoio Built in 124 ms Error: error building site: assemble: "D:\quickstart\content\en\about_index.md:5:1": failed to extract shortcode: template for shortcode "block" not found

hongtaoh commented 1 year ago

@zoeyyuzhao 我自己试了一下,我这里是可以的,说明主题代码没问题。我看了你贴的代码,但是我不知道是哪里的问题。你可以试试代码一行运行完再复制、粘贴、运行下一行。

yuzhao66 commented 1 year ago

谢谢博主,我刚刚一行一行地运行了还是这个问题,不知道为什么在这里困住了好久,我试了下其他主题也还是这个问题

yuzhao66 commented 1 year ago

我搜索了一下错误代码,看到了别人的解决方案,在出错的命令里面加上空格就好了https://djangocas.dev/blog/hugo/hugo-escape-shortcode-in-markdown/ 但是我还是没能运行成功,太艰难了, http://localhost:1313/显示page not found hugo v0.112.3-ba6f74e40420d76f15fc8c2358be90f7aca98e0e+extended windows/amd64 BuildDate=2023-05-24T14:42:50Z VendorInfo=gohugoio WARN 2023/05/28 18:42:37 found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN 2023/05/28 18:42:37 found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN 2023/05/28 18:42:37 found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

yuzhao66 commented 1 year ago

啊!!博主我成功了!我看了这个错误代码后,发现quickstart里面layouts是空的,不知道为什么没有复制过来。然后我把themes里面的layouts文件夹和static文件夹复制到quickstart里了,然后就成功了。但是有个问题是不知道为什么我的右上方是没有那些链接的

yzng2s commented 1 year ago

@hongtaoh 你好,我找到在更新网页内容时到问题所在,我将gh-pages.yml文件中的master改为main后,并且用git push -u origin main(根据我查阅的资料,貌似博主的更新方式都不能用了,至少我这里进行了尝试,无法使用),可以实现将内容同步到github,但是却无法访问我的网页:https://yzng2s.github.io,访问时显示404,请教博主指导一下

yzng2s commented 1 year ago

敬爱的博主:经过几次查询并试验后,发现只需要在建立仓库之前就在设置之中,将Repositories中的main改为master,然后update即可完全参照博主的模板进行,经测试可以实现。总而言之,我的建立过程非常曲折,终于成功了!https://yzng2s.github.io 另外,请教博主,为什么在更新内容后,需要很长一段时间网页上的内容才会更新,是原本github就是如此,还是我的操作存在一定的漏洞,恳请指导。

hongtaoh commented 1 year ago

@zoeyyuzhao 恭喜!我正想发给你,如果还不成功,你可以直接 git clone 这里

我看了这个错误代码后,发现quickstart里面layouts是空的,不知道为什么没有复制过来

这个我也很困惑,不知道是不是 windows 上的终端无法识别其中一行的指令。我不清楚。

但是有个问题是不知道为什么我的右上方是没有那些链接的

我看了你的网站,https://zoeyyuzhao.github.io/,正常啊。不知道你说的是哪些链接

yzng2s commented 1 year ago

敬爱的博主:我的博客已经可以在大约2分钟后就能更新内容了,太感谢你的文章。至上我崇高的敬意!

hongtaoh commented 1 year ago

@yzng2s 你提到的这个 main 和 master,不是个问题。这篇帖子中一直用的都是 master:

git push -u origin master

这行代码就表示分支的名字是 master,不是 main。

将Repositories中的main改为master,然后update即可完全参照博主的模板进行

我猜你是按照 github 给的代码运行的,所以有误 (但这篇帖子中没有提到按照 github 的指令来)。

为什么在更新内容后,需要很长一段时间网页上的内容才会更新,是原本github就是如此,还是我的操作存在一定的漏洞

五分钟以内的话是正常的~

yuzhao66 commented 1 year ago

谢谢博主的回复!我当时设置完hugo这个主题后生成的网页没有 home, post, 中文这些链接,还有点疑惑来着。后来按照你的教程一步步地把代码上传到github上生成的网页就正常了,就有这些链接了,再次感谢博主!!

gr8lawrence commented 1 year ago

博主你好!非常感谢这篇教程,内容十分详细~我除了开始时遇到 @zoeyyuzhao 一样的问题,需要手动复制 layouts 文件夹,后来直到 publish 都很顺利,只不过网站上线后发现 header 上的那一些目录(Hugo logo, home, post, ...) 还是没有生成(https://gr8lawrence.github.io/, 之前在本地用 hugo server -D 也没看到。已经修改了 config.toml 和 hugo.toml,但是这个没有变化,不知道博主能不能帮着分析一下可能的原因?

hongtaoh commented 1 year ago

@gr8lawrence 谢谢你的关注。我把你的个人网站 git clone 到我本地,在本地预览是没问题的,我不知道你这个问题出在哪里。你为什么要手动复制 layouts 呢?大概率是这篇教程有哪个小步骤你没有做,建议你再看一下。另外,如果实在没办法,可以直接克隆 (fork) https://github.com/hongtaoh/hugo-ht-exampleSite ,在这个基础上改也可以。

gr8lawrence commented 1 year ago

谢谢博主回复!我需要手动复制的原因是在完成把hugo-ht中的exampleSite/*archetypes搬到网站母文件夹里这一步后,母文件夹layouts文件夹会是空的(即自生成new site 后都是空的)。如果不复制的话直接hugo server -D会出现下列报错

Error: error building site: assemble: "/Users/gr8lawrence/Documents/personal_website/remake/content/en/about/_index.md:5:1": failed to extract shortcode: template for shortcode "block" not found

这篇文章的码好像并没有复制这个layouts文件夹一说(难道Hugo按理应给会自动生成layouts?小白的我不太懂),但是手动复制后,在本地跑网站会出现一样的问题:上头的目录都是空白。

DuPractice commented 1 year ago

特别特别有帮助,已经建好了,感谢博主无私的分享!

hongtaoh commented 1 year ago

@gr8lawrence 按理说 quickstart 文件夹中 layouts 是空的没关系,因为 themes/hugo-ht 里有 layouts。我目前不清楚为什么你不手动复制的话会出现你提到的错误。

Qiushi-Zhou196 commented 1 year ago

谢谢博主,已经做出来了~

GymRat102 commented 1 year ago

博主你好,我同样遇到和 @gr8lawrence 以及 @yuzhao66 一样的问题。按照步骤操作就会遇到以下报错:

Error: error building site: assemble: "<my-home-dir>/d/quickstart/content/en/about/_index.md:5:1": failed to extract shortcode: template for shortcode "block" not found

当我把 themes/hugo-ht 中的 layouts 和 static 文件夹 cp -r 到网站根目录之后,就可以跑起来了,虽然也出现了顶部没有导航栏。(PS:关于为什么要手动复制,因为 hugo-ht 下面,exampleSite 和 layouts, static 三个文件夹是平行的,所以 cp -r themes/hugo-ht/exampleSite/* . 不会把它们复制出去的)

我再花时间看看怎么解决这个问题(因为主题不是这篇博客的重点),但我确实也遇到了这个问题。


另外,我不太理解为什么要做以下步骤:

mkdir hugo-ht-new # create a new folder called hugo-ht-new
cp -r hugo-ht/* hugo-ht-new # copy everything in hugo-ht to hugo-ht-new
rm -rf hugo-ht # delete the folder of hugo-ht
mv hugo-ht-new hugo-ht # change folder name

我理解可以直接 clone 下来之后继续下面的操作,不需要创建一个新文件夹再移动内容,然后重命名回去。

hongtaoh commented 1 year ago

@GymRat102 第一个问题我现在还不知道是怎么回事,我之后可能会做一期视频来讲。第二个问题,是因为直接 git clone 下来的话,上传会遇到一些问题,因为原始的 .git 信息在里面。肯定有更好的处理方法,但我图省事,就用了最简单粗暴的方法。

GymRat102 commented 1 year ago

我没有走到后面的步骤,忽略了.git的存在,谢谢回复。第一个问题真的很奇怪,如果需要一个复现案例的话,我也可以帮忙重现一下。

yuzhao66 commented 1 year ago

第一个问题可能跟操作系统有关。我第一次是用Windows做的,后来换了新电脑,用Mac做就不需要手动复制了。

hongtaoh commented 1 year ago

@yuzhao66 @GymRat102 感谢两位。我目前手头没有 windows 电脑,之后可能会买一台用来做教程,毕竟大多数人用 windows,不用 mac。感谢回复。

yuzhao66 commented 1 year ago

@yuzhao66 @GymRat102 感谢两位。我目前手头没有 windows 电脑,之后可能会买一台用来做教程,毕竟大多数人用 windows,不用 mac。感谢回复。

我推荐像我一样的小白用桌面端GitHub操作更方便一些,有时候在终端更新网页的时候不知道是不是因为科学上网的原因,会超时,用桌面端直接修改操作更简单🤣

jiahuiSophia commented 11 months ago

Hongtao学长你好!感谢你的教程。我跟着教程做了几遍,仍然无法在branch里面找到gh-pages。terminal里面显示: Reinitialized existing Git repository in C:/Users/XXX/Desktop/quickstart/.git/ On branch master Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean error: remote origin already exists. Everything up-to-date branch 'master' set up to track 'origin/master'. 请问如何解决?谢谢

hongtaoh commented 11 months ago

@jiahuiSophia 问题可能是你每次重新做的时候没有删除之前的 username.github.io 这个仓库。你可以试试每次删除并重建这个仓库。

TONGYUTONY66 commented 10 months ago

学长你好,我在最开始的时候就遇到了问题。

我一次性全部复制您的新建hugo建立代码并运行后:

“cd quickstart/themes git clone https://github.com/hongtaoh/hugo-ht mkdir hugo-ht-new # create a new folder called hugo-ht-new cp -r hugo-ht/ hugo-ht-new # copy everything in hugo-ht to hugo-ht-new rm -rf hugo-ht # delete the folder of hugo-ht mv hugo-ht-new hugo-ht # change folder name cd .. cp -r themes/hugo-ht/exampleSite/ . # copy everything in the exampleSite folder to quickstart cp -r themes/hugo-ht/archetypes . # replace the archetypes folder”

打开http://localhost:1313/,却无法显示网站,终端报错如下:

Error: error building site: assemble: "/Users/xxxx/Desktop/quickstart/content/en/about/_index.md:5:1": failed to extract shortcode: template for shortcode "block" not found

这时候我发现桌面上的quick start文件夹里的layouts 和 content文件夹里是没有东西,好像没有自动复制进去还是咋的。

当我手动将hongtao文件夹里的content, layouts这些更新替换quickstart里面的相同文件夹,网站倒是可以显示了,但缺斤少两:只有小狗图片和下面的文字,右上角的导航bar是没有的。

想请教学长我后续应该如何操作,感谢!

hongtaoh commented 10 months ago

@TONGYUTONY66 这个貌似是操作系统不同导致的。

cp -r hugo-ht/* hugo-ht-new # copy everything in hugo-ht to hugo-ht-new
rm -rf hugo-ht # delete the folder of hugo-ht
mv hugo-ht-new hugo-ht # change folder name

这几行你可以手动弄,不要用代码。更具体的我之后会更新一下这个教程。

TONGYUTONY66 commented 10 months ago

一直跟着前面做,在这一步:“等一两分钟,当出现Your site is published at https://USERNAME.github.io/ 点开那个链接,你的网站应该就出现了。” 我一直没有等到这句话,也没有看到能点击gh-pages的选项。

git init git add . git commit -m "first commit." git remote add origin https://github.com/TONGYUTONY66/TONGYUTONY66.github.io.git git push -u origin main Initialized empty Git repository in /Users/tongyu66/Desktop/quickstart/.git/ warning: adding embedded git repository: themes/hugo-ht hint: You've added another git repository inside your current repository. hint: Clones of the outer repository will not contain the contents of hint: the embedded repository and will not know how to obtain it. hint: If you meant to add a submodule, use: hint: hint: git submodule add themes/hugo-ht hint: hint: If you added this path by mistake, you can remove it from the hint: index with: hint: hint: git rm --cached themes/hugo-ht hint: hint: See "git help submodule" for more information. [main (root-commit) b77443f] first commit. 42 files changed, 1089 insertions(+) create mode 100644 .DS_Store create mode 100644 .github/workflows/gh-pages.yml create mode 100644 .hugo_build.lock create mode 100644 archetypes/default.md create mode 100644 config.toml create mode 100644 content/_index.md create mode 100644 content/cn/_index.md create mode 100644 content/cn/about/_index.md create mode 100644 content/cn/posts/2021-01-07-beiying.md create mode 100644 content/cn/posts/2021-01-07-intro.md create mode 100644 content/cn/posts/_index.md create mode 100644 content/en/_index.md create mode 100644 content/en/about/_index.md create mode 100644 content/en/posts/2021-01-07-road.md create mode 100644 content/en/posts/2021-01-07-test.md create mode 100644 content/en/posts/_index.md create mode 100644 hugo.toml create mode 100644 layouts/404.html create mode 100644 layouts/_default/_markup/render-link.html create mode 100644 layouts/_default/list.html create mode 100644 layouts/_default/single.html create mode 100644 layouts/_default/terms.html create mode 100644 layouts/list-single/list.html create mode 100644 layouts/partials/add-header-anchors.html create mode 100644 layouts/partials/foot_custom.html create mode 100644 layouts/partials/footer.html create mode 100644 layouts/partials/head_custom.html create mode 100644 layouts/partials/header.html create mode 100644 layouts/partials/nav.html create mode 100644 layouts/robots.txt create mode 100644 layouts/shortcodes/bilibili.html create mode 100644 layouts/shortcodes/block.html create mode 100644 layouts/shortcodes/column.html create mode 100644 layouts/shortcodes/columns.html create mode 100644 layouts/shortcodes/end.html create mode 100644 layouts/shortcodes/endcolumn.html create mode 100644 layouts/shortcodes/figure-a.html create mode 100644 layouts/shortcodes/figure.html create mode 100644 layouts/shortcodes/reminder.html create mode 100644 netlify.toml create mode 100644 themes/.DS_Store create mode 160000 themes/hugo-ht Username for 'https://github.com': tongyutony66 Password for 'https://tongyutony66@github.com': remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for 'https://github.com/TONGYUTONY66/TONGYUTONY66.github.io.git/' tongyu66@TongYuMacBook-Air quickstart % git remote add origin https://tongyutony66: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@github.com/TONGYUTONY66/TONGYUTONY66.github.io.git

error: remote origin already exists.

它终端显示是这样的,求学长指教。我也做了两遍了,就是显示不出来。

hongtaoh commented 10 months ago

@TONGYUTONY66 出现这个问题 “adding embedded git repository: themes/hugo-ht” 大概率是因为

cp -r hugo-ht/* hugo-ht-new # copy everything in hugo-ht to hugo-ht-new
rm -rf hugo-ht # delete the folder of hugo-ht
mv hugo-ht-new hugo-ht # change folder name

这几行代码在 windows 中无法正常运行。像我上次提到的那样,你可以问下 chatgpt 这几行代码是做什么的,然后你手动把这些做了,而不是用代码实现。我这个方法很 hecky 不是特别好。

joeliuz6 commented 9 months ago

我也是windows不显示导航栏,换老版本的hugo在windows就好了,用的0.121不行改了0.81

Liangduoyuan commented 9 months ago

博主您好,新人小白想请教下,我到了 brunch 那一步也不显示gh-pages选项,然后我就把库删了重新来一遍,但是到了 depoy key 这一步时生成 key 就显示Key is already in use,但是我已经把原来的库都删了,这该怎么操作呢?我问 chatgpt 也没能解决。

hongtaoh commented 9 months ago

@Liangduoyuan 这个问题我暂时回答不了你。我估计和 windows 操作系统有关系。我之后打算做个视频,这样更清楚一些。

zhidacaishu commented 9 months ago

你好,请问一下你介绍的这种github+hugo的博客搭建方式,能把obsidian软件的markdown格式笔记复制上来直接发布吗?主要是我的笔记有很多公式,尝试了wordpress搭建博客,感觉对带公示的markdown笔记不太友好

hongtaoh commented 9 months ago

@zhidacaishu 好问题。我写过一篇帖子:https://hongtaoh.com/en/2022/05/11/obsedian-mathjax-hugo-convert/

主要针对的就是公示转换问题。但需要手动操作参与。

DanielGuowebsite commented 8 months ago

你好,我在做前面时做到rm -rf hugo-ht 时我终端显示着Remove-Item: A parameter cannot be found that matches parameter name 'rf'.请问怎么办?

hongtaoh commented 8 months ago

你好,我在做前面时做到rm -rf hugo-ht 时我终端显示着Remove-Item: A parameter cannot be found that matches parameter name 'rf'.请问怎么办?

应该是 windows 的问题。这个我得之后再解决了。你可以手动操作,把 hugo-ht 这个文件夹删除

zhidacaishu commented 8 months ago

你好,博主,我在2024-2-7用macbook m1照着你的流程搭建自己的博客已经成功,但是其中的过程有些问题,我在这里写出来方便各位同学参考:

  1. 在网站主题部分,直接执行hugo server -D # 这里的 D 是 draft 的意思会报错Error: error building site: assemble: "/Users/henryzha/Desktop/quickstart/content/en/about/_index.md:5:1": failed to extract shortcode: template for shortcode "block" not found,需要将最后生成的hugo-ht文件夹里的所有内容复制到quickstart文件夹里并替换原文件。
  2. 上传到Github部分,执行完git init git add . git commit -m "first commit." git remote add origin https://github.com/USERNAME/USERNAME.github.io.git git push -u origin master后,需要输入账户名称和密码,密码就是刚才生成的personal token(不是github的密码),如果没有输入,则page的branch选项里不会有gh-pages选项。