csshtml-listsmeta-tagspage-title

How Do I Copy Body Content to Meta Title?


I have an online member directory that we've opened up for Google to crawl. All of the member listings are the organization name as the search result title in search results. I am trying to come up with a way to take the member's name from the listing (perhaps plus a little extra static text) and set that as the Meta Title for each member's unique directory listing page.

The directory listing basically contains the code:

<div id="aaRflVendorDetailOverview">
    <ul>
        <li>John Doe, PhD</li>
        <li>123 Some St. San Fransisco, CA</li>
    </ul>
</div>

I am able to single out just the line from the listing using:

div#aaRflVendorDetailOverview li:first-child

I have not tried too many things because I am not very knowledgeable about this stuff. I am able to single out the line of text (using CSS) that I would like to copy to the header, but I do not know if CSS is capable of doing what I want to do.

Ideally, I would like to take their name line from the listing, "John Doe, PhD" and make the page title into "ABC Member - John Doe, PhD"


Solution

  • It's not possible using CSS, but it is using jQuery.

    This snippet should do the trick:

    $(function () {
    $(document).prop('title', $("#aaRflVendorDetailOverview li:first-child").html());
    });