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

Don't duplicate site title in home page TITLE tag #78

Merged
merged 1 commit into from
Jan 16, 2018

Conversation

denmch
Copy link
Contributor

@denmch denmch commented Jan 15, 2018

Let's say your .Site.Title is "My Website". The code grabs .Site.Title, and then then checks to see if there's a .Title. When you're on the homepage, .Title is equivalent to .Site.Title, so that the browser bar will read:

My Website | My Website

If we qualify .Title by confining it to the .Params namespace, then the site title isn't duplicated:

<title>{{ block "title" . }}{{ .Site.Title }} {{ with .Params.Title }} | {{ . }}{{ end }}{{ end }}</title>

My Website

But it still picks up .Title from posts and pages, where a content title exists in front matter:

My Website | About Me

Let's say your `.Site.Title` is "My Website". The code grabs `.Site.Title`, and then then checks to see if there's a `.Title`. When you're on the homepage, `.Title` is equivalent to `.Site.Title`, so that the browser bar will read:

> My Website | My Website

If we qualify `.Title` by confining to the `.Params` namespace, then the site title isn't duplicated:

```<title>{{ block "title" . }}{{ .Site.Title }} {{ with .Params.Title }} | {{ . }}{{ end }}{{ end }}</title>```

> My Website

But it still picks up `.Title` from posts and pages, where a content title exists in front matter:

> My Website | About Me
@budparr
Copy link
Member

budparr commented Jan 16, 2018

Thanks for this @denmch. Smart idea. I have one other change I'm going to make to the title, but this is good.

@budparr budparr merged commit d5b87cb into theNewDynamic:master Jan 16, 2018
@denmch
Copy link
Contributor Author

denmch commented Jan 16, 2018

Thanks, @budparr. I'm glad you found it helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants