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

Hugo serve fails #220

Closed
sstadick opened this issue Feb 10, 2025 · 4 comments
Closed

Hugo serve fails #220

sstadick opened this issue Feb 10, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@sstadick
Copy link

I followed the set up instructions:

modo init hugo
modo build
hugo serve -s docs/site/

But get the following error:

❯ hugo serve -s docs/site/
go: malformed module path "git@github.com:sstadick/ExtraMojo/docs": invalid char '@'
Hugo provides its own webserver which builds and serves the site.
While hugo server is high performance, it is a webserver with limited options.

The `hugo server` command will by default write and serve files from disk, but
you can render to memory by using the `--renderToMemory` flag. This can be
faster in some cases, but it will consume more memory.

By default hugo will also watch your files for any changes you make and
automatically rebuild the site. It will then live reload any open browser pages
and push the latest content to them. As most Hugo sites are built in a fraction
of a second, you will be able to save and see your changes nearly instantly.

Usage:
  hugo server [command] [flags]
  hugo server [command]

Aliases:
  server, serve

Available Commands:
  trust       Install the local CA in the system trust store.

Flags:
      --appendPort               append port to baseURL (default true)
  -b, --baseURL string           hostname (and path) to the root, e.g. https://spf13.com/
      --bind string              interface to which the server will bind (default "127.0.0.1")
  -D, --buildDrafts              include content marked as draft
  -E, --buildExpired             include expired content
  -F, --buildFuture              include content with publishdate in the future
      --cacheDir string          filesystem path to cache directory
      --cleanDestinationDir      remove files from destination not found in static directories
  -c, --contentDir string        filesystem path to content directory
      --disableBrowserError      do not show build errors in the browser
      --disableFastRender        enables full re-renders on changes
      --disableKinds strings     disable different kind of pages (home, RSS etc.)
      --disableLiveReload        watch without enabling live browser reload on rebuild
      --enableGitInfo            add Git revision, date, author, and CODEOWNERS info to the pages
      --forceSyncStatic          copy all files when static is changed.
      --gc                       enable to run some cleanup tasks (remove unused cache files) after the build
  -h, --help                     help for server
      --ignoreCache              ignores the cache directory
  -l, --layoutDir string         filesystem path to layout directory
      --liveReloadPort int       port for live reloading (i.e. 443 in HTTPS proxy situations) (default -1)
      --minify                   minify any supported output format (HTML, XML etc.)
  -N, --navigateToChanged        navigate to changed content file on live browser reload
      --noChmod                  don't sync permission mode of files
      --noHTTPCache              prevent HTTP caching
      --noTimes                  don't sync modification time of files
  -O, --openBrowser              open the site in a browser after server startup
      --panicOnWarning           panic on first WARNING log
      --poll string              set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes
  -p, --port int                 port on which the server will listen (default 1313)
      --pprof                    enable the pprof server (port 8080)
      --printI18nWarnings        print missing translations
      --printMemoryUsage         print memory usage to screen at intervals
      --printPathWarnings        print warnings on duplicate target paths etc.
      --printUnusedTemplates     print warnings on unused templates.
      --renderSegments strings   named segments to render (configured in the segments config)
      --renderStaticToDisk       serve static files from disk and dynamic files from memory
      --templateMetrics          display metrics about template executions
      --templateMetricsHints     calculate some improvement hints when combined with --templateMetrics
  -t, --theme strings            themes to use (located in /themes/THEMENAME/)
      --tlsAuto                  generate and use locally-trusted certificates.
      --tlsCertFile string       path to TLS certificate file
      --tlsKeyFile string        path to TLS key file
      --trace file               write trace to file (not useful in general)
  -w, --watch                    watch filesystem for changes and recreate as needed (default true)

Global Flags:
      --clock string               set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
      --config string              config file (default is hugo.yaml|json|toml)
      --configDir string           config dir (default "config")
  -d, --destination string         filesystem path to write files to
  -e, --environment string         build environment
      --ignoreVendorPaths string   ignores any _vendor for module paths matching the given Glob pattern
      --logLevel string            log level (debug|info|warn|error)
      --noBuildLock                don't create .hugo_build.lock file
      --quiet                      build in quiet mode
  -M, --renderToMemory             render to memory (mostly useful when running the server)
  -s, --source string              filesystem path to read files relative from
      --themesDir string           filesystem path to themes directory

Use "hugo server [command] --help" for more information about a command.

Error: command error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: go: malformed module path "git@github.com:sstadick/ExtraMojo/docs": invalid char '@'
 *errors.errorString

I had expected that it would locally serve my docs. Maybe this is a hugo issue and not a modo issue?

modo was installed with pip (I also tried the go-install but had the same error). hugo was installed with brew.

> modo --version
Modo v0.11.0
> hugo version
hugo v0.143.1+extended+withdeploy darwin/arm64 BuildDate=2025-02-04T08:57:38Z VendorInfo=brew

This is for docs for ExtraMojo, attempted on this branch: https://github.com/ExtraMojo/ExtraMojo/tree/feat/delim_reader

@mlange-42
Copy link
Owner

Hi @sstadick,
thank you for reporting!

Could you please provide the hugo.yaml and go.mod file that you should find under docs/site?

@mlange-42 mlange-42 added the bug Something isn't working label Feb 10, 2025
@mlange-42
Copy link
Owner

mlange-42 commented Feb 10, 2025

EDIT: the steps below are not required. See the comment below instead

Ah, I think I know what the problem is.

You cloned the repository using SSH, right? I was not aware that the paths of remotes look differently then in your .git/config file.

To fix this, you need to replace your hugo.yaml and go.mod files' contents (in docs/site) by the following.

hugo.yaml

baseURL: https://ExtraMojo.github.io/ExtraMojo/
languageCode: en-us
title: ExtraMojo
disablePathToLower: true

markup:
  highlight:
    style: github-dark

module:
  imports:
    - path: github.com/imfing/hextra

menu:
  main:
    - name: Search
      weight: 1
      params:
        type: search
    - name: GitHub
      weight: 2
      url: "https://github.com/ExtraMojo/ExtraMojo"
      params:
        icon: github

params:
  search:
    enable: true
    type: flexsearch
    flexsearch:
      # index page by: content | summary | heading | title
      index: content
  navbar:
    displayTitle: true
    displayLogo: false

go.mod

module github.com/ExtraMojo/ExtraMojo/docs

go 1.23.0

require (
	github.com/imfing/hextra v0.9.3 // indirect
)

I guess that at least the first line of go.mod is wrong.

To make is work out of the box for SSL-cloned repos, I need to adjust the parser for the git remote.

@mlange-42
Copy link
Owner

I think I fixed this. It would be very helpful if you could give the fix a try instead of fixing yourself manually as described above.

  1. Install the dev version using Go:
    go install github.com/mlange-42/modo@main

  2. Delete modo.yaml and folder docs/

  3. Try again with init, build and Hugo serve

@mlange-42
Copy link
Owner

Fixed in #221. Fix confirmed as working by @sstadick via Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants