|
14 | 14 | package page_test |
15 | 15 |
|
16 | 16 | import ( |
| 17 | + "fmt" |
17 | 18 | "strings" |
18 | 19 | "testing" |
19 | 20 |
|
@@ -435,3 +436,82 @@ title: aBc |
435 | 436 | b = hugolib.Test(t, files) |
436 | 437 | b.AssertFileExists("public/aBc/index.html", true) |
437 | 438 | } |
| 439 | + |
| 440 | +func TestPermalinksTaxonomyAndPageConsistencyIssue14325(t *testing.T) { |
| 441 | + t.Parallel() |
| 442 | + |
| 443 | + filesTemplate := ` |
| 444 | +-- hugo.toml -- |
| 445 | +disableKinds = ['rss','sitemap'] |
| 446 | +%s |
| 447 | +-- content/s1/p1.md -- |
| 448 | +--- |
| 449 | +title: p1 |
| 450 | +date: 2026-04-02 |
| 451 | +tags: ['tag-a'] |
| 452 | +categories: ['category-a'] |
| 453 | +--- |
| 454 | +%s |
| 455 | +-- layouts/all.html -- |
| 456 | +{{ .Title }}| |
| 457 | +` |
| 458 | + |
| 459 | + tests := []struct { |
| 460 | + explicitTermContent bool |
| 461 | + kindSpecificConfig bool |
| 462 | + }{ |
| 463 | + {true, true}, |
| 464 | + {false, true}, |
| 465 | + {true, false}, |
| 466 | + {false, false}, |
| 467 | + } |
| 468 | + |
| 469 | + for _, tt := range tests { |
| 470 | + name := fmt.Sprintf("explicitTermContent=%t/kindSpecificConfig=%t", tt.explicitTermContent, tt.kindSpecificConfig) |
| 471 | + |
| 472 | + t.Run(name, func(t *testing.T) { |
| 473 | + var permalinkConfig, termContent string |
| 474 | + |
| 475 | + if tt.kindSpecificConfig { |
| 476 | + permalinkConfig = ` |
| 477 | +[permalinks.page] |
| 478 | +s1 = '/:year/:month/:day/:contentbasename/' |
| 479 | +[permalinks.term] |
| 480 | +categories = '/:contentbasename/' |
| 481 | +tags = '/tags/:contentbasename/'` |
| 482 | + } else { |
| 483 | + permalinkConfig = ` |
| 484 | +[permalinks] |
| 485 | +s1 = '/:year/:month/:day/:contentbasename/' |
| 486 | +categories = '/:contentbasename/' |
| 487 | +tags = '/tags/:contentbasename/'` |
| 488 | + } |
| 489 | + |
| 490 | + if tt.explicitTermContent { |
| 491 | + termContent = ` |
| 492 | +-- content/categories/category-a/_index.md -- |
| 493 | +--- |
| 494 | +title: Category A (set in front matter) |
| 495 | +--- |
| 496 | +-- content/tags/tag-a/_index.md -- |
| 497 | +--- |
| 498 | +title: Tag A (set in front matter) |
| 499 | +---` |
| 500 | + } |
| 501 | + |
| 502 | + f := fmt.Sprintf(filesTemplate, permalinkConfig, termContent) |
| 503 | + b := hugolib.Test(t, f) |
| 504 | + |
| 505 | + b.AssertFileExists("public/2026/04/02/p1/index.html", true) |
| 506 | + b.AssertFileExists("public/categories/index.html", true) |
| 507 | + b.AssertFileExists("public/category-a/index.html", true) |
| 508 | + b.AssertFileExists("public/index.html", true) |
| 509 | + b.AssertFileExists("public/s1/index.html", true) |
| 510 | + b.AssertFileExists("public/tags/index.html", true) |
| 511 | + b.AssertFileExists("public/tags/tag-a/index.html", true) |
| 512 | + |
| 513 | + b.AssertFileExists("public/categories/category-a/index.html", false) |
| 514 | + b.AssertFileExists("public/s1/p1/index.html", false) |
| 515 | + }) |
| 516 | + } |
| 517 | +} |
0 commit comments