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

Add directory based archetypes #4535

Closed
bep opened this issue Mar 25, 2018 · 1 comment · Fixed by #5229
Closed

Add directory based archetypes #4535

bep opened this issue Mar 25, 2018 · 1 comment · Fixed by #5229
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Mar 25, 2018

Currently, if you organize your content into bundles, you would have to do something like this to create new content with the archetype system:

hugo new post/my-post/index.md

This works as expected, but the added power of bundles with its resource handling (image processing etc.) is screaming for some better support in this department.

This issue suggests that we add support for complete directories below /archetypes. These will be used as a base to create a new bundle (or whatever).

Given this content:

archetypes
├── default.md
└── post-bundle
    ├── bio.md
    ├── images
    │   └── featured.jpg
    └── index.md
hugo new --kind post-bundle post/my-post

Will create a new folder in /content/post/my-post with the same set of files as in the post-bundle archetypes folder.

The handling is simple:

  • We do nothing with the file- or directory names.
  • We parse and execute the content files (md, asciidoc etc.) as Go templates (like we do today) to enable dynamic values.
  • All other files (images etc.) are just copied.

The above example uses the --kind flag. This should also work without it, we just have to decide "who should win" on conflicts with the file based variant.

See https://discourse.gohugo.io/t/archetypal-bundles/11195

@bep bep added this to the v0.39 milestone Mar 25, 2018
@bep bep modified the milestones: v0.39, v0.40 Apr 9, 2018
@bep bep modified the milestones: v0.40, v0.41 Apr 20, 2018
@bep bep modified the milestones: v0.41, v0.42 May 4, 2018
@bep bep modified the milestones: v0.41, v0.42 May 25, 2018
@bep bep modified the milestones: v0.42, v0.43 Jun 5, 2018
@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018
@bep bep modified the milestones: v0.44, v0.45, v0.46 Jul 10, 2018
@bep bep modified the milestones: v0.46, v0.47, v0.48 Aug 3, 2018
@bep bep modified the milestones: v0.48, v0.49 Aug 22, 2018
@bep bep modified the milestones: v0.49, v0.50 Sep 13, 2018
@bep bep self-assigned this Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 19, 2018
bep added a commit to bep/hugoDocs that referenced this issue Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 19, 2018
bep added a commit to bep/hugo that referenced this issue Sep 22, 2018
bep added a commit to bep/hugo that referenced this issue Sep 22, 2018
bep added a commit to bep/hugo that referenced this issue Sep 23, 2018
bep added a commit to bep/hugo that referenced this issue Sep 23, 2018
bep added a commit to bep/hugo that referenced this issue Sep 23, 2018
Given this content:

```bash
archetypes
├── default.md
└── post-bundle
    ├── bio.md
    ├── images
    │   └── featured.jpg
    └── index.md
```

```bash
hugo new --kind post-bundle post/my-post
```

Will create a new folder in `/content/post/my-post` with the same set of files as in the `post-bundle` archetypes folder.

This commit also improves the archetype language detection, so, if you use template code in your content files, the `.Site` you get is for the correct language. This also means that it is now possible to translate strings defined in  the `i18n` bundles,  e.g. `{{ i18n "hello" }}`.

Fixes gohugoio#4535
bep added a commit to bep/hugo that referenced this issue Sep 23, 2018
Given this content:

```bash
archetypes
├── default.md
└── post-bundle
    ├── bio.md
    ├── images
    │   └── featured.jpg
    └── index.md
```

```bash
hugo new --kind post-bundle post/my-post
```

Will create a new folder in `/content/post/my-post` with the same set of files as in the `post-bundle` archetypes folder.

This commit also improves the archetype language detection, so, if you use template code in your content files, the `.Site` you get is for the correct language. This also means that it is now possible to translate strings defined in  the `i18n` bundles,  e.g. `{{ i18n "hello" }}`.

Fixes gohugoio#4535
bep added a commit to bep/hugo that referenced this issue Sep 23, 2018
Given this content:

```bash
archetypes
├── default.md
└── post-bundle
    ├── bio.md
    ├── images
    │   └── featured.jpg
    └── index.md
```

```bash
hugo new --kind post-bundle post/my-post
```

Will create a new folder in `/content/post/my-post` with the same set of files as in the `post-bundle` archetypes folder.

This commit also improves the archetype language detection, so, if you use template code in your content files, the `.Site` you get is for the correct language. This also means that it is now possible to translate strings defined in  the `i18n` bundles,  e.g. `{{ i18n "hello" }}`.

Fixes gohugoio#4535
@bep bep closed this as completed in #5229 Sep 23, 2018
bep added a commit that referenced this issue Sep 23, 2018
Given this content:

```bash
archetypes
├── default.md
└── post-bundle
    ├── bio.md
    ├── images
    │   └── featured.jpg
    └── index.md
```

```bash
hugo new --kind post-bundle post/my-post
```

Will create a new folder in `/content/post/my-post` with the same set of files as in the `post-bundle` archetypes folder.

This commit also improves the archetype language detection, so, if you use template code in your content files, the `.Site` you get is for the correct language. This also means that it is now possible to translate strings defined in  the `i18n` bundles,  e.g. `{{ i18n "hello" }}`.

Fixes #4535
bep added a commit that referenced this issue Sep 24, 2018
bep added a commit to gohugoio/hugoDocs that referenced this issue Sep 24, 2018
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant