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

hugolib: Extract title from filename #5336

Closed
wants to merge 1 commit into from

Conversation

maxandersen
Copy link
Contributor

@maxandersen maxandersen commented Oct 20, 2018

Why:

  • Would be nice to just add content without a frontmatter.
    title is at the moment the only required field in frontmatter for
    hugo.
  • Like to migrate existing content more easily to frontmatter.
    Existing static generators can derive title from filename or content
    markup.

This change addreses the need by:

  • use the same mechanics added for handling date fields in
    commit: 68bf151 to allow configure how title is configured.

    The default for doing title is simply:

    [frontmatter]
    title = [ "title" ]

    So, if you want to use a different field than title this works:

    [frontmatter]
    title = [ "mytitle", ":default" ]

    This commit adds support for deriving title from filename and possible
    to combine with filename suppor for dates.

    A good configuration for deriving date and titles from filenames while still
    honoring values found in frontmatter are:

    [frontmatter]
    date = [ ":default", "filename" ]
    title = [ ":default", "filename" ]

    Fixes Use filename as title when it’s not defined in front matter #3805

Why:

 * Would be nice to just add content without a frontmatter.
   title is at the moment the only required field in frontmatter for
   hugo.
 * Like to migrate existing content more easily to frontmatter.
   Existing static generators can derive title from filename or content
   markup.

This change addreses the need by:

 * use the same mechanics added for handling date fields in
   commit: 68bf151 to allow configure how title is configured.

   The default for doing title is simply:

   ```toml
   [frontmatter]
   title = [ "title" ]
   ```

   So, if you want to use a different field than `title` this works:

   ```toml
   [frontmatter]
   title = [ "mytitle", ":default" ]
   ```

   This commit adds support for deriving title from filename and possible
   to combine with filename suppor for dates.

   A good configuration for deriving date and titles from filenames while still
   honoring values found in frontmatter are:

   ```toml
   [frontmatter]
   date = [ ":default", "filename" ]
   title = [ ":default", "filename" ]
   ```

   Fixes gohugoio#3805
@maxandersen
Copy link
Contributor Author

whoops - bad commit; redoing.

@github-actions
Copy link

github-actions bot commented Feb 1, 2022

This pull request 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 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use filename as title when it’s not defined in front matter
1 participant