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

Using mounts module breaks the theme #290

Open
lobopraveen opened this issue Aug 11, 2020 · 3 comments
Open

Using mounts module breaks the theme #290

lobopraveen opened this issue Aug 11, 2020 · 3 comments

Comments

@lobopraveen
Copy link
Contributor

lobopraveen commented Aug 11, 2020

Steps to reproduce

  1. Clone this repo git clone https://github.com/MunifTanjim/minimo.git
  2. cd minimo/exampleSite
  3. Edit the config file to point the theme to minimo theme and add mounts module as shown below
theme = "../../../minimo"

[module]
  [[module.mounts]]
    source = "public"
    target = "static"
  1. Create public directory mkdir public
  2. hugo server renders the site properly; however, if you just build the site using hugo, all the files under public/assets/ are zero byte files. Somehow the files are getting copied over from the theme's static directory to the publish directory (public) as zero byte files.

Hugo Static Site Generator v0.74.3/extended linux/amd64

Just to make sure that this not an issue with Hugo and the mounts module usage as shown above, I grabbed the second theme from Hugo themes collection and added the mounts module exactly as shown above and the theme's CSS and JS files were copied properly. I'm thinking this could be something to do with the minimo theme.

lobopraveen added a commit to lobopraveen/praveenlobo.com that referenced this issue Aug 12, 2020
Once I switched to using the mounts module, the website broke. Somehow
the theme's static files were all zero bytes in the Hugo's publish
directory. See MunifTanjim/minimo#290

To overcome this issue, this commit will add another mounts configuration
to mount the theme's static directory as static directory. This has fixed
the issue in local machine.
@MunifTanjim
Copy link
Owner

Can't reproduce 🤔 Which hugo version are you using? @lobopraveen

@lobopraveen
Copy link
Contributor Author

I tried the same steps now and it worked. So to recreate what I was trying to do, I created the public directory before step 4 and I'm able to reproduce the issue. I will update the steps.

@lobopraveen
Copy link
Contributor Author

While trying to recreate I tried again with hugo-theme-codex theme. It works even when I follow the exact same steps .

I ran into something strange. In hugo-theme-codex, after followed the steps, I just deleted the about css files under public/css and ran hugo command, it recreated the file but it was a zero byte file. I reran hugo command and the file went from zero byte to the correct file with 4.7kB. I randomly started deleting the css and js file and running hugo without any change and the result was not consistent. Some times the file would reappear as zero byte and then proper size and sometimes it would just take couple of more retries of hugo command. Sometimes it would come right back on first try.

I think this is because of the circular dependency! Hugo command creates the site files and puts them in the public directory amd the static directory gets copied to the public directory as well. Now that the public directory is also mounted as the static, I'm guessing that it creates some kind of circular dependency or infinite loop and the result random.

The surprising thing is that the behavior in minimo theme is consistent. It just creates zero byte files and doesn't flip back even when I run the hugo command back to back a dozen times.

I just assumed that

  1. Hugo will first mount/download public directory as static
  2. build and copy the site content to the public directory and at that time the static content (from the mounts module) gets overwritten because static content came from the public directory

You may close this if you don't see any issue in your theme. It probably needs an answer from the Hugo developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants