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

Setup deploy-preview on Netlify to test PRs #79

Closed
khos2ow opened this issue Sep 9, 2018 · 18 comments
Closed

Setup deploy-preview on Netlify to test PRs #79

khos2ow opened this issue Sep 9, 2018 · 18 comments

Comments

@khos2ow
Copy link
Contributor

khos2ow commented Sep 9, 2018

Although this is a theme and not an actual website, but essentially every change we push (thorough pull requests) should be tested against exampleSite and we can easily setup a deploy-preview pipeline on Netlify to generate the example site for that particular PR at hand to be able to immediately see the change in action without the need to pull down the PR locally to test..

But first we need to solve for or come up with a workaround (hopefully not checking-in resources folder) for the fact that Netlify cannot handle Hugo extended in their CI.

@luizdepra
Copy link
Owner

luizdepra commented Sep 14, 2018

There is another problem related with "not checking-in resources folder". Hugo's theme showcase apparently doesn't build the resources for us. I'm trying to know if they really don't do this.
If negative, we'll need to add the 'resources' folder into the repository. There is no other way,

This sucks because we'll have to remember and rebuild the resources every time we change the something in the SCSS files. It is easy to forget and pull a broken version. But, in the other hand, the final users won't need to use the extended version anymore (unless they want to override something).

@luizdepra
Copy link
Owner

Yep. There is no way.
gohugoio/hugoThemes#412 (comment)

I just added the resources folder and a new release Makefile command.

I'll update the README with the steps to make a release as soon as possible.

@khos2ow
Copy link
Contributor Author

khos2ow commented Sep 14, 2018

Whoa. That sucks! I kinda understand position of Netlify to not have extended in their binrc base image, but the showcase of Hugo itself won't handle extended is kind of ironic.

But at least on the bright side, we can proceed with deploy-preview.

@DewaldDeJager
Copy link

I'm trying to deploy my personal site via Netlify but due to the above I am getting the following error:

10:47:29 PM: Executing user command: hugo
10:47:29 PM: ERROR 2018/09/21 20:47:29 Failed to add template "posts/single.html" in path "posts/single.html": template: posts/single.html:23: function "resources" not defined
10:47:29 PM: ERROR 2018/09/21 20:47:29 Failed to add template "_default/list.html" in path "_default/list.html": template: _default/list.html:23: function "resources" not defined
10:47:29 PM: ERROR 2018/09/21 20:47:29 Failed to add template "_default/single.html" in path "_default/single.html": template: _default/single.html:23: function "resources" not defined
10:47:29 PM: ERROR 2018/09/21 20:47:29 Failed to add template "index.html" in path "index.html": template: index.html:23: function "resources" not defined
10:47:29 PM: ERROR 2018/09/21 20:47:29 Failed to add template "404.html" in path "404.html": template: 404.html:23: function "resources" not defined
10:47:29 PM: ERROR 2018/09/21 20:47:29 Current theme does not support Hugo version 0.42. Minimum version required is 0.43
10:47:29 PM: Building sites … ERROR 2018/09/21 20:47:29 Error while rendering "page" in "": template: "_default/single.html" is an incomplete or empty template

As a workaround, I thought I could build locally and then drag-and-drop the site folder onto Netlify (They also allow this for deploys). Looking into the release Makefile command that @luizdepra added, I did not make much progress. The steps I followed were:

[dearvolt@vostro dearvolt.com]$ cd themes/coder/
[dearvolt@vostro coder]$ ls
archetypes  assets  exampleSite  images  layouts  LICENSE.md  Makefile  README.md  resources  static  theme.toml
[dearvolt@vostro coder]$ make clean release

I then open the demo/public/index.html page and the site is unstyled. This is the exact same issue I am facing when just running hugo in the project root directory. Example screenshot:

screenshot_2018-09-21 john doe

Any ideas on how I can get my site production ready, bearing the above in mind? The site can be found in this repo.

Thank you for the awesome theme and I hope I can contribute!

@luizdepra
Copy link
Owner

luizdepra commented Sep 22, 2018

@DewaldDeJager, your site at netlify is using a old version of Hugo. hugo-coder needs at least verion 0.43. Look at this log line.

10:47:29 PM: ERROR 2018/09/21 20:47:29 Current theme does not support Hugo version 0.42. Minimum version required is 0.43

Running locally, did you try running make demo and accessing localhost:1313?

@luizdepra
Copy link
Owner

I just downloaded your site and ran hugo serve -D. Everything looks fine, except the avatar that doesn't appear. I'm using Hugo v0.48/extended.

@DewaldDeJager
Copy link

DewaldDeJager commented Sep 22, 2018

@luizdepra I have already tried updating the Hugo version to 0.48 on Netlify. I am running 0.48-1 locally. When I run hugo server -D everything works fine for me (Including the avatar), but as soon as I run a static build (hugo) then the site looks like the screenshot above.

I get the same behaviour when running make demo. The site works fine until I run a release build.

EDIT: I don't think my change took effect. I just changed the Hugo version on Netlify again and now it works. I still don't know why running hugo locally and then opening public/index.html shows the unstyled website though.

@luizdepra
Copy link
Owner

luizdepra commented Sep 22, 2018

I still don't know why running hugo locally and then opening public/index.html shows the unstyled website though.

This is normal browser behavior, right? Did you try to use a simple webserver to test it?
Try running python -m SimpleHTTPServer or python3 -m http.server inside the public folder.

@AndiSusanto15
Copy link

AndiSusanto15 commented Sep 22, 2018

before I apologize for my English. why when I run the hugo command, that my posts doesn't appear in the public folder?

@AndiSusanto15
Copy link

its awesome themes.

@DewaldDeJager
Copy link

@AndiSusanto15 Have you tried running hugo server -D and then going to http://localhost:1313/ ? If you want to build it into the public folder, just run hugo.

@DewaldDeJager
Copy link

@luizdepra You're right, I think it is the absolute URL breaking when you open the index.html file directly. Funny enough, the network tab in my debugger console doesn't show the attempt to load the stylesheet.

@AndiSusanto15
Copy link

@DewaldDeJager to generate draft mode must add -D flags, hahahaha. i'm noob.

@khos2ow
Copy link
Contributor Author

khos2ow commented Oct 3, 2018

@luizdepra since we already have resources checked in the repo, any reason why not setup this integration?

@luizdepra
Copy link
Owner

luizdepra commented Oct 3, 2018

Sure. But I don't think this is simple.
I can't simply add this repository to Netlify and run with Hugo configuration because I need the demo folder created first. I need to test if the current Makefile will work with Netlify. I suspect that Hugow can be a problem here.

@luizdepra
Copy link
Owner

Ok, I figured it out.
We need a PR to test the deploy hooks. hehehe

@khos2ow
Copy link
Contributor Author

khos2ow commented Oct 4, 2018

Here's a PR for you: #90 , but the way you setup this integration can be better, I'll send another PR for that.

@khos2ow
Copy link
Contributor Author

khos2ow commented Oct 4, 2018

and IMO this is the better way of deploying PRs to Netlify: #91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants