Skip to content
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

Support Hugo extended #884

Closed
ugurcemozturk opened this issue Jul 22, 2020 · 18 comments
Closed

Support Hugo extended #884

ugurcemozturk opened this issue Jul 22, 2020 · 18 comments
Labels
archived This issue has been locked. feature-request New feature or request

Comments

@ugurcemozturk
Copy link

Is your feature request related to a problem? Please describe.
With default build spec for Hugo, there isn't support for SCSS files which is a feature of Hugo extended. Most of the hugo templates requires SCSS support so Hugo extended version.

Describe the solution you'd like
There can be another build spec for extended version. There is a sample at https://michaux.co/posts/specifying-hugo-version-on-aws-amplify/

Additional context
I believe most of the Amplify users who needs Hugo extended got this issue. It may end up with at least %50 customer lost at this stage.

@ganipcanot ganipcanot added the feature-request New feature or request label Jul 23, 2020
@ganipcanot
Copy link

Thanks for the suggestion! For now it seems the workaround to pin the Hugo version does work but I will add this as a backlog item to prioritize.

version: 0.1
frontend:
  phases:
    build:
      commands:
        - wget https://github.com/gohugoio/hugo/releases/download/v0.55.4/hugo_0.55.4_Linux-64bit.tar.gz
        - tar -xf hugo_0.55.4_Linux-64bit.tar.gz hugo
        - mv hugo /usr/bin/hugo
        - rm -rf hugo_0.55.4_Linux-64bit.tar.gz
        - hugo
  artifacts:
    baseDirectory: public
    files:
      - '**/*'
  cache:
    paths: []

@hervenivon
Copy link

You can set the hugo version from the console: "App settings" > "Build settings" > "Build image settings" > "Live package updates" > "Add package version override"

image

@rich4j
Copy link

rich4j commented Oct 30, 2020

I tried to set the hugo package to extended_{version} using the _LIVE_UPDATES env var but it didn't seem to do the trick..

I settled on a manual install in my amplify.yml

preBuild:
  commands:
    - wget https://github.com/gohugoio/hugo/releases/download/v0.76.5/hugo_extended_0.76.5_Linux-64bit.tar.gz
    - tar -xf hugo_extended_0.76.5_Linux-64bit.tar.gz hugo
    - mv hugo /usr/bin/hugo
    - rm -rf hugo_extended_0.76.5_Linux-64bit.tar.gz

@Vlaaaaaaad
Copy link

I spent a couple of hours on this due to Amplify doing some weird quote removal/escaping thingie. In case anybody wants to live on the edge and always use the latest version of Hugo extended, here's the config required:

version: 1

frontend:
  phases:
    preBuild:
      commands:
        - curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "browser_download_url.*hugo_extended.*_Linux-64bit\.tar\.gz" | cut -d ":" -f 2,3 | tr -d '\\"' | wget -qi -
        - tar -xzf "$(find . -name "*Linux-64bit.tar.gz")"
        - chmod +x hugo
        - mv hugo /usr/bin/hugo
        - rm -rf "$(find . -name '*Linux-64bit.tar.gz')"
        - hugo version
    build:
      commands:
        - hugo
  artifacts:
    ...

@laiconsulting
Copy link

Is there a proper solution yet?
This workaround misses the patches Amplify applies to Hugo, which isn't optimal.

@pagles
Copy link

pagles commented Oct 13, 2021

Same workaround more or less as what everyone has posted with the addition of following the latest hugo version in amplify by using the preset VERSION_HUGO env var:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - wget https://github.com/gohugoio/hugo/releases/download/v${VERSION_HUGO}/hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - tar --overwrite -xf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz hugo
        - mv hugo /usr/bin/hugo
        - rm -rf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - hugo version
    build:
      commands:
        - hugo
  artifacts:
    baseDirectory: public
    files:
      - '**/*'
  cache:
    paths: []

This was an intermediate solution for me as I actually set my own env var with the hugo version I want installed and used but just thought I would post it if anyone is interested. Still a workaround of course.

@juev
Copy link

juev commented Dec 8, 2021

Do you have any news?

@aimeeu
Copy link

aimeeu commented Feb 17, 2022

Will this ever be worked on? Most docs-as-code Hugo users need the extended version of Hugo.

@HazardPassado
Copy link

Still a problem. In the hopes of saving other lost souls on google, my error on build, using the hugo-book theme was:
Error: Error building site: TOCSS: failed to transform "book.scss" (text/x-scss): resource "scss/book.scss_50fc8c04e12a2f59027287995557ceff" not found in file cache

The workaround provided by @pagles worked well (thanks,) but official support is obviously preferable.

olivierlemasle added a commit to olivierlemasle/amplify-hosting that referenced this issue Feb 23, 2023
@AbdAllahAbdElFattah13
Copy link

Hey,

Same issue here, used the worked around by @pagles for now, but official support defiantly preferable.

@mattsunner
Copy link

Following up to keep this alive...

work arounds by @pagles & @Vlaaaaaaad both are working at this time. Still waiting for official support.

@hurrellit
Copy link

hurrellit commented Oct 13, 2023

Does anyone have a working Amplify build yml? I am tearing my hair out with this and I'd love to get it working, but I currently cannot. Using @pagles workaround listed above with the Hugo version override set to "latest" under "Live package updates":

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - wget https://github.com/gohugoio/hugo/releases/download/v${VERSION_HUGO}/hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - tar --overwrite -xf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz hugo
        - mv hugo /usr/bin/hugo
        - rm -rf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - hugo version
    # IMPORTANT - Please verify your build commands
    build:
      commands:
        - hugo
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: /
    files:
      - '**/*'
  cache:
    paths: []

Gets this error:

Error: Error building site: "/codebuild/output/src3034530210/src/doc/content/en/_index.md:6:1": failed to extract shortcode: template for shortcode "blocks/cover" not found
2023-10-13T15:33:30.681Z [ERROR]: !!! Build failed

Because Amplify is still taking v0.75.1 where this shortcode is not supported:

Executing command: wget https://github.com/gohugoio/hugo/releases/download/v${VERSION_HUGO}/hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
2023-10-13T15:33:29.002Z [WARNING]: --2023-10-13 15:33:28--  https://github.com/gohugoio/hugo/releases/download/v0.75.1/hugo_extended_0.75.1_Linux-64bit.tar.gz

I even tried specifying 0.119.0 in the prebuild command section rather than VERSION_HUGO and disabling the override under Live package updates", and this results in an error about missing the "go" module.....

2023-10-13T15:41:48.837Z [WARNING]: 2023-10-13 15:41:48 (53.9 MB/s) - ‘hugo_extended_0.119.0_Linux-64bit.tar.gz’ saved [21155031/21155031]
2023-10-13T15:41:48.837Z [INFO]: # Executing command: tar --overwrite -xf hugo_extended_0.119.0_Linux-64bit.tar.gz hugo
2023-10-13T15:41:49.343Z [INFO]: # Executing command: mv hugo /usr/bin/hugo
2023-10-13T15:41:49.382Z [INFO]: # Executing command: rm -rf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
2023-10-13T15:41:49.404Z [INFO]: # Executing command: hugo version
2023-10-13T15:41:49.488Z [INFO]: hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended linux/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio
2023-10-13T15:41:49.489Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2023-10-13T15:41:49.489Z [INFO]: # Executing command: hugo
2023-10-13T15:41:49.691Z [INFO]: Total in 167 ms
                                 Error: failed to load modules: failed to download modules: binary with name "go" not found
2023-10-13T15:41:49.694Z [ERROR]: !!! Build failed

The Hugo doc (https://gohugo.io/hosting-and-deployment/hosting-on-aws-amplify/) made it sound so easy, but I've lost the better part of an afternoon messing around!
Any tips gratefully received. Thank you.

@HazardPassado
Copy link

@hurrellit

I just tested that workaround. My build.yml looks like your first example.

    preBuild:
      commands:
        - wget https://github.com/gohugoio/hugo/releases/download/v${VERSION_HUGO}/hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - tar --overwrite -xf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz hugo
        - mv hugo /usr/bin/hugo
        - rm -rf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - hugo version

Still works for me with Hugo version 0.118.2. I also tested 0.119.0 without issue. The only difference which comes to mind is that I did not use the Live package updates. Instead, I set VERSION_HUGO under Environment Variables. Try this:

  1. Use the above build.yml
  2. Disable live version overrides
  3. Set VERSION_HUGO in environment variables to 0.119.0

You might also check that Amplify is picking up that it's a Hugo site, under App Settings > General > Framework. My value reads "Hugo"

@hurrellit
Copy link

@HazardPassado

Thanks for replying!

So I tried your suggestion and this time it picked the correct latest version 0.119.0 via the environment variable, but it's still choking on the missing "go" module:

2023-10-13T19:39:00.681Z [WARNING]: 2023-10-13 19:39:00 (49.2 MB/s) - ‘hugo_extended_0.119.0_Linux-64bit.tar.gz’ saved [21155031/21155031]
2023-10-13T19:39:00.681Z [INFO]: # Executing command: tar --overwrite -xf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz hugo
2023-10-13T19:39:01.235Z [INFO]: # Executing command: mv hugo /usr/bin/hugo
2023-10-13T19:39:01.274Z [INFO]: # Executing command: rm -rf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
2023-10-13T19:39:01.277Z [INFO]: # Executing command: hugo version
2023-10-13T19:39:01.358Z [INFO]: hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended linux/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio
2023-10-13T19:39:01.360Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
                                 # Executing command: hugo
2023-10-13T19:39:01.496Z [INFO]: Total in 103 ms
                                 Error: failed to load modules: failed to download modules: binary with name "go" not found

However, as you suggested I checked the framework and Amplify is detecting my project as "web" and not "Hugo". I guess this might have something to do with it?

My repo is in gitlab.com, and I'm using the Git sub modules method, which i suppose could be linked too...

@hurrellit
Copy link

I have now got this to work. It appears that for my "Go" issue, the "default" image that Amplify offers does not have Go defined on the system PATH environment variable. Once I defined that, it then choked on the familiar PostCSS issue, which was easily rectified with an npm install command

Anyway for any other lost souls on the internet, this is my build config in Amplify that is now working (don't forget to change your baseUrl in hugo.toml).

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - wget https://go.dev/dl/go1.21.3.linux-amd64.tar.gz
        - rm -rf /usr/local/go 
        - tar -C /usr/local -xzf go1.21.3.linux-amd64.tar.gz
        - rm -rf go1.21.3.linux-amd64.tar.gz
        - wget https://github.com/gohugoio/hugo/releases/download/v${VERSION_HUGO}/hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - tar --overwrite -xf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz hugo
        - mv hugo /usr/bin/hugo
        - rm -rf hugo_extended_${VERSION_HUGO}_Linux-64bit.tar.gz
        - hugo version
        - npm install --save-dev autoprefixer postcss-cli postcss
    # IMPORTANT - Please verify your build commands
    build:
      commands:
        - export PATH=$PATH:/usr/local/go/bin
        - go version
        - hugo
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: public
    files:
      - '**/*'
  cache:
    paths: []

@calavera
Copy link
Contributor

calavera commented Nov 27, 2023

The new amplify:2023 build image has Hugo Extended installed by default. You can choose this image in your Amplify app's build settings.

image

If you need to install a newer version than the one in this new image, you can use NPM, the maintainers of Hugo provide a package that's very easy to install npm install -g hugo-extended: https://www.npmjs.com/package/hugo-extended

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Nov 27, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. feature-request New feature or request
Projects
None yet
Development

No branches or pull requests