srackham / hindsite

hindsite is a fast, lightweight static website generator.
MIT License
2 stars 2 forks source link

Grab current page filename #9

Closed tyeeman closed 1 week ago

tyeeman commented 1 month ago

Your documentation is great but I can't seem to find how to get the variable for the page filename.

.page gives me the full url but I only need the filename plus ext if available.

The reason is I want to create a link on my page to a specific newsletter like below. Now the tricky part is that this link is in a newsletter email and I want the link to go to the webpage with the same newsletter.

I will hardcode https://www.site.com/posts/ but need the filename to append to that like this

https://www.site.com/posts/{{.file}}.html

I know .file does not exist so is there a var that gives just the filename?

I tried .slug and it works but I don't need a new slug. If there is something already available I would like to use it.

srackham commented 1 month ago

There is no template variable containing the file name, you may be able to extract it from the .url using Go template pipelines and functions, see https://pkg.go.dev/text/template

tyeeman commented 1 month ago

I'm using .slug even though I have to enter it in the meta area every time I make a new md file -

https://www.site.com/posts/{{.slug}}.html