# Site defaults
defaults:
-
scope:
path: "" # an empty string here means all files in the project
type: "posts" # previously `post` in Jekyll 2.2.
values:
layout: "default"
author: "Jonathan Gossage"
and I am trying to use the author variable in my default.html as shown below:
I have tried to access the default variable as site.author and as author without success. How should I reference default variables? Variables such as page.author are referenced without a problem.
I am having problems rendering the above message properly. The second part of the message contains HTML which gets rendered even when it is formatted as “preformatted text”.
I believe what you have at the top are default page variables not site variables. So any files in the scope should have those page variables available automatically.
If you add author: "someone cool" outside of that defaults block - not indented - then you should be able to access it via site.author.
{{ author }} isn’t going to work with what you have above.
The YAML front matter defaults you’re defining above for type: "posts" are all scoped at the page level. Meaning you’d access author with {{ page.author }} not {{ author }}, which would give you <p>Author: Jonathan Gossage</p>.
it means that all posts will by default use the default.html layout and have “Jonathan Gossage” as the post’s author. If you have a post with no front matter or a post with an empty front matter will have the above values for page.layout and page.author.
To override the default, simply re-define the key in the post’s front matter: