Setting TITLE using text from H1 header in Dreamweaver
Here's a little code snippet that might make your life easier. If you wanted to set your page title to include the text from your header (in my case, the
H1 element) you can use this search and replace. Pop open the Find dialog and select Source Code from the Search drop down. Enter the following into the Find field:
Luckily, Dreamweaver's regular expression support isn't greedy so this will find your
title tag your
h1 tag and everything in between. All we need to do now is rearrange things. Enter the following in the replace field.
<title>$4 - Site Name</title>$2<h1>$4</h1>
The dollar sign and number combo identify which set of parentheses to take. Therefore, we replace our match with our new title tag to include the third parentheses (our heading) along with the site name. We then put in all the content between the title and the heading with $2. Finally, we tack on our heading as is.
Once things are ready to go, make sure Use regular expression is checked and then click Find or Replace as you need to.
I can't stress this enough. Before doing ANY site wide search and replace, ALWAYS make a backup first. Trust me on this one!
The only downfall to this method is that any tags that are present in the heading (line breaks, bolds, italics, etc) will suddenly appear in the title. Dreamweaver to the rescue again.
To clean up any tags that appear in the header, open up the Find dialog again and then choose Specific Tag from the Search dropdown. Select [any tag] from the dropdown beside it.
Select Inside Tag from the dropdown with the [+][-] beside it and then choose title from the dropdown beside that. Select Strip Tag from the Action dropdown. Click Replace All and you're good to go.