Git Product home page Git Product logo

heroku-buildpack-hugo's Introduction

Heroku buildpack: Hugo

This is a Heroku buildpack for sites powered by Hugo. It uses the latest stable version of Hugo.

Usage

Create a Heroku application using this buildpack:

$ heroku create --buildpack https://github.com/roperzh/heroku-buildpack-hugo.git

or configure your existent application:

$ heroku buildpacks:set BUILDPACK_URL="https://github.com/roperzh/heroku-buildpack-hugo.git"

Optionally, define a HUGO_VERSION Config Var to specify the Hugo version you wish to use:

$ heroku config:set HUGO_VERSION=0.25

Then simply git push to heroku and open your application!

$ git push heroku master
$ heroku open

Using themes

This buildpack provides a simple api to use custom themes, just add a .hugotheme file in the root of your application with the url of your theme.

Example

To fetch the great hyde theme:

https://github.com/spf13/hyde.git

Here is an example application, and here is the code.

Alternative method

If you don't like the idea of a .hugotheme file, you can simply manage your themes with git submodules. Heroku will take care to fetch all the submodules in your project.

Important notes

Don't forget to configure your hugo baseurl with the url of your application, using https:// not http://

Contributing

1- Fork it

2- Create your feature branch (git checkout -b my-new-feature)

3- Commit your changes (git commit -am 'Add some feature')

4- Push to the branch (git push origin my-new-feature)

5- Create new Pull Request

License

The MIT License (MIT)

Copyright (c) 2015 Roberto Dip

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

heroku-buildpack-hugo's People

Contributors

davidkeutgens avatar jbergler avatar manojavan avatar moto5 avatar purplebooth avatar roperzh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heroku-buildpack-hugo's Issues

Theme not applied to https:// when base_url is http://

Hi @roperzh

I thought I had the same issue as #7

When I run the hugo server on local host all is fine and the site shows the theme but when I view via "heroku open" after the build I see not formatting as though the theme is not applied but no errors are generated.

I've realised that when I visit the "http://" site (which is the base_url in my config.toml) then I see the site, however "heroku open" sends you to "https://" and this shows the text but no theme applied.

When changing the base_url to "https://..." both http and https work fine.

I suggest amending the readme to say:

"Don't forget to configure your hugo baseurl with the url of your application, using https:// not http://"

Best
/moto5

No post content in index.html

I have created a working Hugo site and tested it locally. This is my second Hugo site, so not a total noob, but no expert either... When I follow your directions for the Heroku buildpack and push, almost everything looks good, except post content (example: post/name/index.html) are blank files. I get a 200 response, so the file is there, but it is empty. Generating public locally gives complete post file contents.
Heroku site is here: https://ajj2.herokuapp.com
fyi I am using an auto deploy from github to heroku.

Not serving public folder

Thanks for the buildpack! Any help here would be really appreciated.

When I use it, I end up getting the root directory served, and not the public folder.

That doesn't really make sense, because I can see that the public folder is being served:

web: "cd public && python -m SimpleHTTPServer \$PORT"

I am using this pack with Dokku. It creates the following NGINX config for me:


server {
  listen      [::]:80;
  listen      80;
  server_name lukewm.info; 
  access_log  /var/log/nginx/lukewm.info-access.log;
  error_log   /var/log/nginx/lukewm.info-error.log;

  return 301 https://$host:443$request_uri;

}

server {
  listen      [::]:443 ssl ;
  listen      443 ssl ;
  
  server_name lukewm.info; 
  access_log  /var/log/nginx/lukewm.info-access.log;
  error_log   /var/log/nginx/lukewm.info-error.log;

  ssl_certificate     /home/dokku/lukewm.info/tls/server.crt;
  ssl_certificate_key /home/dokku/lukewm.info/tls/server.key;
  ssl_protocols       TLSv1.2;
  ssl_prefer_server_ciphers on;

  keepalive_timeout   70;
  

  location    / {
    gzip on;
    gzip_min_length  1100;
    gzip_buffers  4 32k;
    gzip_types    text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml  application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
    gzip_vary on;
    gzip_comp_level  6;

    proxy_pass  http://lukewm.info-5000;
    
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Request-Start $msec;
  }
  include /home/dokku/lukewm.info/nginx.conf.d/*.conf;

  error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
  location /400-error.html {
    root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
    internal;
  }

  error_page 404 /404-error.html;
  location /404-error.html {
    root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
    internal;
  }

  error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
  location /500-error.html {
    root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
    internal;
  }
}

upstream lukewm.info-5000 {

  server 172.17.0.7:5000;

}

My site is at https://lukewm.info/. My configuration is at https://git.coop/lwm/lukewm.info.

Use an ENV variable instead of a .hugotheme file

Personally, I never liked the .hugotheme approach, and I'm wondering if would be possible to use an ENV variable to handle this.

Of course, the idea is to keep the whole .hugotheme functionality for compatibility.

Buildpack Broken

Log:

-----> Hugo app detected
-----> Fetching Hugo 0.17 binaries at https://github.com/spf13/hugo/releases/download/v0.17/hugo_0.17_Linux_64bit.tar.gz
-----> Extracting Hugo 0.17 binaries to /tmp/build_e230f40b0865547778cd99166b099a43/dreamhouseapp-dreamhouse-site-d634daae16a00a18304ec1f365939a2240ad0282/vendor/hugo
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
mv: cannot stat ???/app/tmp/cache/hugo_0.17_Linux_64bit/hugo_0.17_Linux_64bit???: No such file or directory
-----> Building the site
/app/tmp/buildpacks/d433e4b22f300c1306f372b71ecbd96e8ad7f3813a544f9e2b155809a1ac5f566b59b1e95d60e6d3b2b6a1626191823a2155ca517e6eec6ab9616f80bd243ff1/bin/compile: 48: /app/tmp/buildpacks/d433e4b22f300c1306f372b71ecbd96e8ad7f3813a544f9e2b155809a1ac5f566b59b1e95d60e6d3b2b6a1626191823a2155ca517e6eec6ab9616f80bd243ff1/bin/compile: ./hugo: not found

Implementing CORS

Hi, there.

It would be really great to be able to have CORS support. Since custom domains typically need this on Heroku...

Thanks!

Force SSL

hey @roperzh great stuff, thanks a lot! Is there a way to force SSL? Or, more generally, to setup 301 redirects?

Allow specifying the baseURL as an environment variable

It would be very useful to have a way of specifying the baseURL as an environment variable.
Currently I have the baseURL set to my https://www.mysite.com in config.toml.

However this means that the staging app https://mysite-staging.herokuapp.com/ is broken since it looks for all CSS and JS at the baseURL specified in config.toml.

Is there a way of setting hugo --baseURL=HEROKU_ENV_BASEURL in the buildpack?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.