301 redirect

I’m new to Hugo but I was able to migrate my WordPress blog over in about 3 days, everything is perfect, except I build a docker image and run my blog inside of a k8s cluster and everything works until I click on a tag, for some reason I get a redirect 301 whenever I visit /tags/ is there something special there? My Dockerfile is below so what happens is when you click on a tag you get a 301 to url:5000/tags/ instead of url/tags/ I’ve looked in the generated html to see if there is a redirect directive but it’s not there; so as a work around I am using the npm package serve which runs on port 5000 and everything is fine, I will assume serve works because it’s a “dumb” web server?? but nginx is seeing something that makes it do a redirect?? also this same behavior shows up if I just run a docker container on my host system with the below params; again everything works except for /tags it does a 301 redirect to url:port/tags/

FROM local/nginx-unprivileged:1.18.0

LABEL maintainer="Fabian Brash"

WORKDIR /usr/share/nginx/html

COPY public/ .

# RUN as non-root

USER 1000

EXPOSE 5000

CMD ["nginx", "-g", "daemon off;"]

Docker command:

docker run -d --name c1 -p 80:5000 imagename

but of course this works

docker run -d --name c1 -p 5000:5000 imagename

Can you run your hugo site locally with hugo server and replicate the issue?

no the issue does not appear but that makes sense because I’m accessing everything like so:

http://localhost:1313/tags/hugo/

So nothing is going in 1 port and coming out another

So I had a look @ the network tab and sure enough there is a 301 redirect

As you can see in the image, but look at the below image this is using the serve package

serve ignores the 301 and that’s why it works there’s probably an option to honor 301 redirects but of course I’m not using it I’m just doing

cd public && serve

serve

Bottom line question: has Hugo done it’s job or not? Is it generating bad code? If not, I’d suggest seeking out docker+nginx help elsewhere.

Yes it is working, and I do have another question out there in a docker forum but it seems the 301 is originating from the Hugo config somewhere and I wanted to see if this was a known thing/limitation in Hugo; again I have a workaround for this.