gobwa
February 7, 2023, 8:49pm
1
Hello all,
The code example in the Archetypes documentation
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---
...
I understand that we’re retrieving the name of the markdown file which uses this archetype and the date at which the markdown was created. At first I thought the context would be the page, but that doesn’t seem right, since the frontmatter for a new markdown file wouldn’t exist right after being created by calling hugo new
command (if i understood this forum post correctly).
I looked through the documentation some more but, can’t figure out what context the dot (.) has in a archetypes markdown. I found the .Name variable under Shortcode Variables (which i think is definitely not it).
All help appreciated, thank you in advance!
Regular page
Command
hugo new content/en/posts/post-1.md
Values inserted in markdown
Action
Value
{{ .Date }}
2023-02-07T14:01:33-08:00
{{ .Name }}
post-1 (returns .Page.File.ContentBaseName)
{{ .Type }}
posts
{{ .Page.File.BaseFileName }}
post-1
{{ .Page.File.ContentBaseName }}
post-1
{{ .Page.File.Dir }}
posts/
{{ .Page.File.Ext }}
md
{{ .Page.File.LogicalName }}
post-1.md
{{ .Page.File.Path }}
posts/post-1.md
{{ .Page.File.TranslationBaseName }}
post-1
{{ .Page.File.UniqueID }}
11100be4dc48b9153759ce466b02d6ed
{{ .Page.Site }}
Site("My Site")
{{ .Page.Site.LanguageCode }}
en-US
{{ .Page.Site.Title }}
My Site
{{ .Site }}
Site("My Site") (returns .Page.Site)
{{ mul 6 7 }}
42 (you can use any function)
Leaf Bundle
Command
hugo new content/en/posts/post-2/index.md
Values inserted in markdown
Action
Value
{{ .Date }}
2023-02-07T14:05:04-08:00
{{ .Name }}
post-2 (returns .Page.File.ContentBaseName)
{{ .Type }}
posts
{{ .Page.File.BaseFileName }}
index
{{ .Page.File.ContentBaseName }}
post-2
{{ .Page.File.Dir }}
posts/post-2/
{{ .Page.File.Ext }}
md
{{ .Page.File.LogicalName }}
index.md
{{ .Page.File.Path }}
posts/post-2/index.md
{{ .Page.File.TranslationBaseName }}
index
{{ .Page.File.UniqueID }}
1e8f8595b3abc8dc24e306ff0d8ff78b
{{ .Page.Site }}
Site("My Site")
{{ .Page.Site.LanguageCode }}
en-US
{{ .Page.Site.Title }}
My Site
{{ .Site }}
Site("My Site") (returns .Page.Site)
{{ mul 6 7 }}
42 (you can use any function)
Branch bundle
Command
hugo new content/en/posts/_index.md
Values inserted in markdown
Action
Value
{{ .Date }}
2023-02-07T14:06:04-08:00
{{ .Name }}
posts (returns .Page.File.ContentBaseName)
{{ .Type }}
posts
{{ .Page.File.BaseFileName }}
_index
{{ .Page.File.ContentBaseName }}
posts
{{ .Page.File.Dir }}
posts/
{{ .Page.File.Ext }}
md
{{ .Page.File.LogicalName }}
_index.md
{{ .Page.File.Path }}
posts/_index.md
{{ .Page.File.TranslationBaseName }}
_index
{{ .Page.File.UniqueID }}
a74dbcb35ee06db2c5314e7ff0d9268f
{{ .Page.Site }}
Site("My Site")
{{ .Page.Site.LanguageCode }}
en-US
{{ .Page.Site.Title }}
My Site
{{ .Site }}
Site("My Site") (returns .Page.Site)
{{ mul 6 7 }}
42 (you can use any function)
2 Likes
gobwa
February 7, 2023, 10:13pm
3
sorry i missed that! Thank you for making the tables for me
system
Closed
February 9, 2023, 10:13pm
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.