gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.63k stars 7.45k forks source link

Lookup order of archetype is not honored when theme is specified #4052

Closed ashishthedev closed 6 years ago

ashishthedev commented 6 years ago

Even though I've specified a theme and there is an archetype present for a content-section(posts), but the front matter is not being copied from the theme.

Referring section from docs:

https://gohugo.io/content-management/archetypes/

Lookup Order for Archetypes Similar to the lookup order for templates in your layouts directory, Hugo looks for a section- or type-specific archetype, then a default archetype, and finally an internal archetype that ships with Hugo. For example, Hugo will look for an archetype for content/posts/my-first-post.md in the following order:

archetypes/posts.md archetypes/default.md themes//archetypes/posts.md themes//archetypes/default.md (Auto-generated with hugo new site) If you wish to use archetypes that ship with a theme, the theme field must be specified in your configuration file.

Step1: Create a new theme: $ hugo new theme bingo

Step2: Use the theme in config.toml $ vi config.toml +++ ... theme = "bingo" +++

Step3: create a new archetype posts $ vi themes/bingo/archetypes/posts.md +++ fancyOption = "yay" +++

Step4: Create a new post $ hugo new posts/first.md

Step5: Inspect the new file $ cat content/posts/first.md

---
title: "One"
date: 2017-11-04T18:56:43+05:30
draft: true
---

$ hugo version Hugo Static Site Generator v0.30.2 linux/386 BuildDate: 2017-10-27T14:26:46+05:30

bep commented 6 years ago

Do you have a default archetype in your project?

ashishthedev commented 6 years ago

Yes.

.
├── archetypes
│   └── default.md
├── config.toml
├── content
│   └── posts
│       ├── one.md
│       └── two.md
├── data
├── layouts
├── static
└── themes
    └── bingo
        ├── archetypes
        │   ├── default.md
        │   └── posts.md
        ├── layouts
        │   ├── 404.html
        │   ├── _default
        │   │   ├── list.html
        │   │   └── single.html
        │   ├── index.html
        │   └── partials
        │       ├── footer.html
        │       └── header.html
        ├── LICENSE.md
        ├── static
        │   ├── css
        │   └── js
        └── theme.toml
ashishthedev commented 6 years ago

Also observed that the front matter is in yaml instead of toml.

bep commented 6 years ago

Yes.

Then he behaviour is in line with the documentation. Note that this has been discussed before.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.