New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo new fails when no archetype files #3626

Closed
jinleileiking opened this Issue Jun 22, 2017 · 13 comments

Comments

Projects
None yet
5 participants
@jinleileiking
➜  bookshelf git:(master) ✗ hugo new post/axxxx.md -v
INFO 2017/06/22 13:15:16 Using config file:
INFO 2017/06/22 13:15:16 attempting to create "post/axxxx.md" of "post" of ext ".md"
Error: open : no such file or directory
➜  bookshelf git:(master) ✗ hugo version
Hugo Static Site Generator v0.25-DEV linux/amd64 BuildDate: 2017-06-22T11:30:10+08:00
➜  bookshelf git:(master) ✗ uname -a
Linux tjwq01-ibu-video007106.tjwq01.ksyun.com 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
@jinleileiking

This comment has been minimized.

Show comment
Hide comment
@jinleileiking

jinleileiking Jun 22, 2017

CentOS release 6.5 (Final)

CentOS release 6.5 (Final)

@anthonyfok anthonyfok added the Bug label Jun 22, 2017

@anthonyfok

This comment has been minimized.

Show comment
Hide comment
@anthonyfok

anthonyfok Jun 22, 2017

Contributor

Thank you for reporting this, @jinleileiking!

I was able to reproduce this in a freshly created Hugo site where hugo new site is just run and archetypes/ contains no file in v0.24.

Temporary workaround: Create an archetypes/default.md file with the following minimal content:

+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = {{ .Date }}
draft = true
+++
Contributor

anthonyfok commented Jun 22, 2017

Thank you for reporting this, @jinleileiking!

I was able to reproduce this in a freshly created Hugo site where hugo new site is just run and archetypes/ contains no file in v0.24.

Temporary workaround: Create an archetypes/default.md file with the following minimal content:

+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = {{ .Date }}
draft = true
+++
@jinleileiking

This comment has been minimized.

Show comment
Hide comment

worked for me @anthonyfok

@jinleileiking

This comment has been minimized.

Show comment
Hide comment
@jinleileiking

jinleileiking Jun 22, 2017

but when run the server fail:

➜  bookshelf git:(master) ✗ hugo server --bind "0.0.0.0" -p 8441 --buildDrafts --theme=hugo_theme_robust
Started building sites ...
ERROR 2017/06/22 13:41:27 failed to parse page metadata for "post/former.md": Near line 2 (last key parsed ''): expected a top-level item to end with a newline, comment, or EOF, but got '+' instead
Error: Error building site: Errors reading pages: Error: failed to parse page metadata for "post/former.md": Near line 2 (last key parsed ''): expected a top-level item to end with a newline, comment, or EOF, but got '+' instead for former.md
➜  bookshelf git:(m

but when run the server fail:

➜  bookshelf git:(master) ✗ hugo server --bind "0.0.0.0" -p 8441 --buildDrafts --theme=hugo_theme_robust
Started building sites ...
ERROR 2017/06/22 13:41:27 failed to parse page metadata for "post/former.md": Near line 2 (last key parsed ''): expected a top-level item to end with a newline, comment, or EOF, but got '+' instead
Error: Error building site: Errors reading pages: Error: failed to parse page metadata for "post/former.md": Near line 2 (last key parsed ''): expected a top-level item to end with a newline, comment, or EOF, but got '+' instead for former.md
➜  bookshelf git:(m
@jinleileiking

This comment has been minimized.

Show comment
Hide comment
@jinleileiking

jinleileiking Jun 22, 2017

➜  bookshelf git:(master) ✗ cat content/post/former.md
+++
title = "Former"
date = 2017-06-22T13:39:12+08:00
draft = true

+++

# go

go build, go get 都不行,是因为目录名和go原始包里的名字冲突了:sync

[root@vm10-65-136-13 sync]# go build consumer.go

➜  bookshelf git:(master) ✗ cat content/post/former.md
+++
title = "Former"
date = 2017-06-22T13:39:12+08:00
draft = true

+++

# go

go build, go get 都不行,是因为目录名和go原始包里的名字冲突了:sync

[root@vm10-65-136-13 sync]# go build consumer.go

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 22, 2017

Member

Yes, this is my mistake.

The fix would be:

  1. To make sure hugo new works without any archetype file
  2. That hugo new site creates a sensibel empty archetype/default.md file.
Member

bep commented Jun 22, 2017

Yes, this is my mistake.

The fix would be:

  1. To make sure hugo new works without any archetype file
  2. That hugo new site creates a sensibel empty archetype/default.md file.

@bep bep changed the title from hugo new failed to hugo new fails when no archetype files Jun 22, 2017

@bep bep added this to the v0.24.1 milestone Jun 22, 2017

@jinleileiking

This comment has been minimized.

Show comment
Hide comment
@jinleileiking

jinleileiking Jun 22, 2017

@anthonyfok

date = {{ .Date }} --> date = "{{ .Date }}"

buggie?

@anthonyfok

date = {{ .Date }} --> date = "{{ .Date }}"

buggie?

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 22, 2017

Member

buggie?

No, the spec clearly states which format Date is on. But we should provide a date that also works unquoted with TOML. I will create another issue for that.

Member

bep commented Jun 22, 2017

buggie?

No, the spec clearly states which format Date is on. But we should provide a date that also works unquoted with TOML. I will create another issue for that.

@anthonyfok

This comment has been minimized.

Show comment
Hide comment
@anthonyfok

anthonyfok Jun 22, 2017

Contributor

Oh! The + in 2017-06-22T13:39:12+08:00 trips it!

I live in the - timezone, so a date like 2017-06-21T23:47:42-06:00 works fine.

Contributor

anthonyfok commented Jun 22, 2017

Oh! The + in 2017-06-22T13:39:12+08:00 trips it!

I live in the - timezone, so a date like 2017-06-21T23:47:42-06:00 works fine.

@siben168

This comment has been minimized.

Show comment
Hide comment
@siben168

siben168 Jun 22, 2017

@anthonyfok i'm a new user of Hugo on windows, have exactly same issue mentioned here, the workaround you provided is valid, however, there are warns as following, is it because some files don't exist?

D:\Work\ericblog>hugo new test.md -v
....
WARN 2017/06/22 16:56:19 Translation func for language en not found, use default.
WARN 2017/06/22 16:56:19 i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.
D:\Work\ericblog\content\test.md created

siben168 commented Jun 22, 2017

@anthonyfok i'm a new user of Hugo on windows, have exactly same issue mentioned here, the workaround you provided is valid, however, there are warns as following, is it because some files don't exist?

D:\Work\ericblog>hugo new test.md -v
....
WARN 2017/06/22 16:56:19 Translation func for language en not found, use default.
WARN 2017/06/22 16:56:19 i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.
D:\Work\ericblog\content\test.md created

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 22, 2017

Member

@siben168 those warnings are unrelated, and they are warnings; not important if you don't use translations.

Member

bep commented Jun 22, 2017

@siben168 those warnings are unrelated, and they are warnings; not important if you don't use translations.

bep added a commit to bep/hugo that referenced this issue Jun 22, 2017

bep added a commit to bep/hugo that referenced this issue Jun 22, 2017

@bep bep closed this in e908d95 Jun 22, 2017

bep added a commit that referenced this issue Jun 22, 2017

bep added a commit that referenced this issue Jun 24, 2017

@kgilmer

This comment has been minimized.

Show comment
Hide comment
@kgilmer

kgilmer Jun 20, 2018

I am seeing this issue using the Ubuntu 16.04 Hugo package and following the official tutorial at step 4.

Looks like the package is pretty old, I guess I'll build from source.

$ hugo version
Hugo Static Site Generator v0.16-DEV BuildDate: 2016-02-06T09:14:17-08:00

kgilmer commented Jun 20, 2018

I am seeing this issue using the Ubuntu 16.04 Hugo package and following the official tutorial at step 4.

Looks like the package is pretty old, I guess I'll build from source.

$ hugo version
Hugo Static Site Generator v0.16-DEV BuildDate: 2016-02-06T09:14:17-08:00
@anthonyfok

This comment has been minimized.

Show comment
Hide comment
@anthonyfok

anthonyfok Jun 20, 2018

Contributor

Hi @kgilmer,

You may also try to install the Hugo .deb package from Ubuntu 18.04 LTS or even in cosmic, see https://packages.ubuntu.com/hugo

Another option is to use the Hugo snap by running snap install hugo (might need to use sudo).

Contributor

anthonyfok commented Jun 20, 2018

Hi @kgilmer,

You may also try to install the Hugo .deb package from Ubuntu 18.04 LTS or even in cosmic, see https://packages.ubuntu.com/hugo

Another option is to use the Hugo snap by running snap install hugo (might need to use sudo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment