I’m trying to use Netlify Dev (or Netlify CLI) in combination with
Hugo server. I’m doing this so I’m able to use the Netlify functions locally.
For Netlify Dev, you can specify options. I have the following:
framework = "#custom"
command = "hugo server && cp _redirects public/_redirects"
targetPort = 1313
publish = "public"
When I run
netlify dev, it successfully runs the
hugo server command and the site is accessible via http://localhost:1313/ but when I visit http://localhost:8888 (which is Netlify’s local server), I get a
As a guess, I assume this is something to do with hugo server overriding the baseURL to set it to localhost:1313?
Any help is much appreciated.
Hi Dave, could you please ask that question in the Netlify Discourse and let us know their answer afterwards? I am very interested in this, but also I am pretty sure that nobody here might be able to help you. The Netlify people are even more friendly than we and it’s a good question.
It’s very Netlify specific.
On a second read: What’s inside your
_redirects file? And what is the baseHREF value in your config? It reads like 1313 is redirected to 8888 and hugo then makes everything 1313 based again. There is a CLI configuration that let’s you configure which port to use.
But still, I am pretty sure the Netlify Community has that solution faster than we.
I’ve posted here: https://community.netlify.com/t/netlify-dev-and-hugo-throwing-a-err-too-many-redirects-error/27837/2
On a second read: What’s inside your _redirects file? And what is the baseHREF value in your config? It reads like 1313 is redirected to 8888 and hugo then makes everything 1313 based again. There is a CLI configuration that let’s you configure which port to use.
The redirects file contains basic redirect such as /bla/ to /bla2/.
Removing all the configurations from Netlify dev doesn’t build it correctly and the localhost:8888 works but obviously doesn’t watch for changes.
See what Netlify Discourse comes back with!