luizdepra / hugo-coder

A minimalist blog theme for hugo.
MIT License
2.69k stars 1.05k forks source link

Issues with the "coder" theme's style not being loaded in a Docker context #39

Closed Drillan767 closed 6 years ago

Drillan767 commented 6 years ago

Hello, my problem seems specific, I don't really know what to do:

I started to use Hugo just a few hours ago, I only needed to have a single page and nothing else, so I decided to use a theme, found yours, pulled it, followed your indications (editing the config.toml file) and it worked like a charm. For the context, it was with a Windows 8.0 64 bits computer. I didn't have to run make build, only had to restart the server.

I pulled my code from a Debian environment and created a Dockerfile to deploy the website along with my other Docker projects, here it is:

FROM debian:stretch

RUN apt-get -qq update \
        && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends ca-certificates asciidoc build-essential \
        && rm -rf /var/lib/apt/lists/*

ENV HUGO_VERSION 0.42.1
ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb

ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb
RUN dpkg -i /tmp/hugo.deb \
        && rm /tmp/hugo.deb

RUN mkdir /usr/share/landing
WORKDIR /usr/share/landing
COPY . /usr/share/landing
RUN git clone https://github.com/luizdepra/hugo-coder.git themes/coder

EXPOSE 1313

ONBUILD ADD site/ /usr/share/blog
ONBUILD RUN hugo -d /usr/share/nginx/html/

# By default, serve site
ENV HUGO_BASE_URL http://localhost:1313
CMD hugo server -b ${HUGO_BASE_URL} --bind=0.0.0.0

I realized that since you had to git pull a project inside the "themes" directory, you can't push the whole thing, you'll have to download it again after, so that's what I did in my Dockerfile (else, the website looks like a blank page)

However, once done, something is missing. Here is a link to my website. As you can see, the fonts, styles and such are not loading.

What am I missing? Thank you in advance

P.S. I managed to run make build, but nothing changed

luizdepra commented 6 years ago

Looking at the source code of the your website, I found this:

<link rel="stylesheet" href="http://localhost:1313/css/style.min.css">

hugo-coder uses absolute URLs, so it completes CSS address with the baseurl. See absURL. You can try to modify the theme and use relURL instead. Also, I suspect that if you run your site with hugo server, it will use your internal URL (HUGO_BASE_URL) ignoring baseurl config.

I just curious... Why not serve your static website with nginx, caddy or any other web server?

Drillan767 commented 6 years ago

Thank you for your answsers, I'll look into it

For your curiosity, I just wanted to make sure your theme was working before using any web server, this was the next step.

Which makes me think that if I directly used a web server, maybe I wouldn't have this problem...

khos2ow commented 6 years ago

One of the main reason to use Hugo (and any hugo-theme for that matter) is to statically generate the site, what you're trying to do doesn't make much sense to me. I mean it defeats the whole purpose of using hugo.

But one thing I might want to dockerize is the hugo itself, e.g. on my staging/review environment, to not to need to install any extra binaries/packages.

Drillan767 commented 6 years ago

So I've been digging, and now I understand why both of you were telling me that what I did was nonsense, and how much of a nonsense it was. TL;DR, I needed to run hugo, just like that, and handle the generated static website with something else. I currently have problem doing this, but this another problem for other people.

My deepest apologies, and thank you!