Skip to content

multilingual: Warn when resources are discarded #12079

@jmooring

Description

@jmooring

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)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions