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

Adding Content (images in different locale subdirs) #1108

Closed
wrex opened this issue Jul 18, 2022 · 11 comments
Closed

Adding Content (images in different locale subdirs) #1108

wrex opened this issue Jul 18, 2022 · 11 comments

Comments

@wrex
Copy link

wrex commented Jul 18, 2022

This section caused me some confusion while playing with docsy again for the first time in ages:

To customize the large landing image, which is in a cover block, replace the content/en/featured-background.jpg file in your project with your own image (it can be called whatever you like as long as it has background in the file name). You can remove or add as many blocks as you like, as well as adding your own custom content.

I replaced the default background image in the example site, but only did it in the en subdirectory (I forgot there was another locale). Unfortunately (I think because fa sorts after en), this meant that changing the background image had no effect whatsoever. I was pulling my hair out refreshing caches, restarting the server with and without FastRebuild, etc. trying to figure out where the old image was coming from. I finally realized the old image was getting pulled from the fa content directory on each rebuild.

I'm unsure if this is a documentation issue, a sample-site issue, or an issue with docsy or hugo itself, but at the very least it would be nice if the documentation mentioned that images and other assets in page bundles need to be the same across locale subdirectories. It seems to me the background images should be DRYed up somehow in the sample site. I'm not sure that locale-specific images make sense and only the markdown and html should vary between locales. Having the same image in multiple locale subdirectories feels wrong.

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 26, 2022

Hmm, let me take a look at the code/URL that's pulling that image - it seems like it should be possible to single source it, but the ways of Hugo are sometimes mysterious....

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 27, 2022

So it is indeed Hugo weirdness, the cover block is looking for the image as a page resource which means it has to be in the same "bundle" (directory with an index file at the root) as the page. Going to poke around some more and see if there's a nice way of having common resources across different language dirs other than just sticking them all in the /static/ directory.

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 27, 2022

Though also, hmm ....https://gohugo.io/content-management/multilingual/#page-bundles, so it should just work. Let me look at the rules more closely.

Our example site has a Norwegian version that has no specific background cover image of its own and it serves up just fine: https://example.docsy.dev/no/

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 27, 2022

Did you actually remove the image from the fa directory? It looks like the behaviour is to pull the image from the top-weighted language directory if there's nothing matching in the current language-specific directory. So if you just have a cover image in one directory, that becomes your single source of truth.

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 27, 2022

Also I hadn't realized there was an actual image in the fa directory in the example site - I think because the community member who added it as a RTL example just copied everything across. I'll add a PR to remove it. Do you think we should also add something to the docs for multilanguage, even just adding a link to the Hugo doc above?

LisaFC added a commit to google/docsy-example that referenced this issue Jul 27, 2022
Remove superfluous background image - Hugo should just pull the cover image from the default language `en` directory.

See google/docsy#1108
LisaFC added a commit to google/docsy-example that referenced this issue Jul 27, 2022
Remove superfluous background image - Hugo should just pull the cover image from the default language `en` directory.

See google/docsy#1108
@wrex
Copy link
Author

wrex commented Jul 27, 2022

I'm still pre-coffee, but after re-cloning the example site into a new directory:

# rex @ rexs-imac in ~/Public/repos/docsy on git:master x [9:33:02]
$ hugo server
hugo: collected modules in 619 ms
Error: from config: failed to resolve output format "print" from site config

(edit config.toml to remove "print" from the section array)

# rex @ rexs-imac in ~/Public/repos/docsy on git:master x [9:33:24] C:255
$ hugo server
hugo: collected modules in 564 ms
Start building sites …
hugo v0.101.0+extended darwin/amd64 BuildDate=unknown
Error: Error building site: "/Users/rex/Public/repos/docsy/content/no/_index.html:7:1": failed to extract shortcode: template for shortcode "blocks/cover" not found
Built in 144 ms

Am I missing something obvious?

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 27, 2022

I wonder are you running into #805, could be some kind of caching issue? What version of Hugo are you using?

@wrex
Copy link
Author

wrex commented Jul 27, 2022

hugo v0.101.0+extended darwin/amd64 BuildDate=unknown

Let me get some coffee and see if there's something weird with my environment. Brand new git clone, though, so it seems odd.


Edit: On a mac currently running 12.4, about to update to 12.5. Fingers crossed.

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 27, 2022

That is odd. It's building fine straight from the repo with Netlify, think we're Hugo v0.100.1 there (should update).

@wrex
Copy link
Author

wrex commented Jul 27, 2022

Aaaaand two hours later my iMac is up on 12.5, hugo was persuaded to re-download modules, and everything is working normally. (In my professional life, "oh well, that fixed it" would never suffice, I'd insist on figuring out the root cause to ensure it doesn't happen again. Since this is a personal project, however, I've zero interest in exploring further. 😁)

Anyway, I'm happy to report that #181 (simply removing the redundant image in other locales) worked fine.

I'm not sure why I didn't think to try that originally instead of removing entire locale subdirectories (possibly related to my tiredness from beating my head against the wall trying to figure out why that image wasn't changing).

Thanks for your help!

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 28, 2022

No problem, happy to help.

@LisaFC LisaFC closed this as completed Jul 28, 2022
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