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

multilingual: Warn when resources are discarded #12079

Open
jmooring opened this issue Feb 20, 2024 · 7 comments
Open

multilingual: Warn when resources are discarded #12079

jmooring opened this issue Feb 20, 2024 · 7 comments

Comments

@jmooring
Copy link
Member

jmooring commented Feb 20, 2024

Reference: https://discourse.gohugo.io/t/hugo-v0-123-0-images-are-not-showing-up-any-more/48359/9

This is a goofy setup to begin with, but maybe we should warn users if we're going to discard resources.

content/
├── de/
│   └── s1/
│       └── files/        <-- branch bundle
│           ├── _index.md
│           └── a.txt
└── en/
    └── s1/
        └── files/        <-- just a dumb directory of s1 page resources
            └── b.txt

Build with v0.122.0

public/
├── de/
│   ├── s1/
│   │   ├── files/
│   │   │   ├── a.txt
│   │   │   └── index.html
│   │   └── index.html
│   └── index.html
├── en/
│   ├── s1/
│   │   └── files/
│   │       └── b.txt  <-- discarded with v0.123.0 (see below)
│   └── index.html
└── index.html

Build with v0.123.0

public/
├── de/
│   ├── s1/
│   │   ├── files/
│   │   │   ├── a.txt
│   │   │   └── index.html
│   │   └── index.html
│   └── index.html
├── en/
│   └── index.html
└── index.html
test case
func TestFoo(t *testing.T) {
	t.Parallel()

	files := `
-- config.toml --
disableKinds = ['rss','sitemap','taxonomy','term']
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
[languages.en]
contentDir = 'content/en'
weight = 1
[languages.de]
contentDir = 'content/de'
weight = 2
-- layouts/_default/list.html --
{{ .Title }}
-- content/de/s1/files/_index.md --
---
title: irrelevant
---
-- content/de/s1/files/a.txt --
I am de/s1/files/a.txt
--
-- content/en/s1/files/b.txt --
I am en/s1/files/b.txt
  `

	b := hugolib.Test(t, files)

	b.AssertFileExists("public/de/s1/files/index.html", true)
	b.AssertFileExists("public/en/s1/files/index.html", false)
	b.AssertFileExists("public/de/s1/files/a.txt", true)
	// This is the failing test:
	b.AssertFileExists("public/en/s1/files/b.txt", true)
}

@bep
Copy link
Member

bep commented Feb 20, 2024

It's not obvious to me what happens in the example above.

@jmooring
Copy link
Member Author

Do I need to clarify anything, or are you commenting about what's actually happening?

@bep
Copy link
Member

bep commented Feb 20, 2024

No, I'm just saying that I need to check how we treat the case above before I can determine if it's right or wrong or if its possible/practical to warn about it.

@j0hax
Copy link

j0hax commented Feb 21, 2024

Hi, I'm also affected by this issue. In my case I am publishing mixed-language university notes, using either index.md oder index.de.md for my files depending on the language of the material.

# Abbreviated excerpts from my hugo.toml

languageCode = 'en-US'

[languages]
  [languages.de]
    languageCode = 'de-DE'
    languageDirection = 'ltr'
    languageName = 'Deutsch'
  [languages.en]
    languageCode = 'en-US'
    languageDirection = 'ltr'
    languageName = 'English'

Note the following example, the ai and compiler-theory branch bundles are localized as en-US (my default language), while the ds branch is German. Hugo v0.123.1 has completely removed the ability to see any images I have for German course notes.

content/notes/
├── ai
│   ├── csp.md
│   ├── _index.md
│   ├── mdp.md
│   ├── rl.md
│   └── search.md
├── compiler-theory
│   ├── _index.md
│   ├── lambdacalculus.md
│   ├── sml.md
│   └── types.md
├── ds
│   ├── algebra.de.md
│   ├── binomial.de.md
│   ├── counting.de.md
│   ├── graphs.de.md
│   ├── _index.de.md
│   ├── recursive.de.md
│   ├── solutions
│   │   ├── algebraische-strukturen.de.md
│   │   ├── graphentheorie
│   │   │   ├── adjgraph.png
│   │   │   ├── index.de.md
│   │   ├── _index.de.md
│   │   ├── kombinatorik.de.md
│   │   └── rekursionsgleichungen
│   │       ├── index.de.md
│   │       └── steine.png
│   ├── spicker
│   │   ├── index.de.md
│   │   ├── scan-back.jpg
│   │   └── scan.jpg
│   └── stirling.de.md
├── _index.de.md
├── _index.md

@jmooring
Copy link
Member Author

This may or may not be the same issue. Can you please share your site repo with us so that we don't have to recreate/guess?

@j0hax
Copy link

j0hax commented Feb 21, 2024

Of course: https://github.com/j0hax/j0hax.github.io/

Multilingual pages are under /content/notes/

@jmooring
Copy link
Member Author

@j0hax I have opened a separate issue for your problem. See #12107.

@bep bep modified the milestones: v0.123.2, v0.123.3, v0.123.4, v0.123.5, v0.123.6 Feb 23, 2024
@bep bep modified the milestones: v0.123.6, v0.123.7, v0.123.8, v0.123.9 Mar 1, 2024
@bep bep modified the milestones: v0.123.9, v0.124.1 Mar 18, 2024
@bep bep modified the milestones: v0.124.1, v0.124.2 Mar 26, 2024
@bep bep modified the milestones: v0.124.2, v0.126.0 Apr 17, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants