Search
Clear search
Close search
Google apps
Main menu
true

Modify XSLT to display metadata value as document title

Summary: The document title that GSA displays in search results is either the html <title> tag or from a complex algorithm that generates the title from the page contents.

Title generation is different for various document types. If you are feeding the content, and the main content of a page is base64 encoded, the title is from one of the meta fields.

In some cases you might want to use specific values as the title of a document.

Fix: You can alter your XSLT front end to display a specific metadata value as the title in search results.

Here is a simple example of a document body:

<!DOCTYPE html>
<html>
<head>
    <meta name="Article type" content="free release" />
    <meta name="Issuer" content="Daily News" />
</head>
<body>
<h1>evening Newspaper</h1>
<p>My first paragraph.</p>
</body>
</html>

This example document returns the following title in search results:

Step1 Check search results

Follow the steps below to change the title in GSA results to "Daily News."

  1. Go to Search > Search Features > Front Ends in the GSA Admin Console.
  2. Next to the front end you want to modify, click Edit.
  3. Under XSLT Stylesheet Editor, click Edit underlying XSLT code. Step2 Edit Frontend
  4. Change this section of existing XSLT
    From:
        <xsl:choose>
        <xsl:when test="T">
            <span class= "goog-trans-section l" transId="gadget_{$res_num}">
                <xsl:call-template name="reformat_keyword">
                    <xsl:with-param name="orig_string" select="T"/>
                </xsl:call-template>
            </span>
        </xsl:when>
        <xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
    </xsl:choose>

    To:
       <xsl:choose> 
        <xsl:when test="MT/@N='Issuer' and MT/@V!=''"> 
            <xsl:value-of select="MT[@N = 'Issuer']/@V"/> 
        </xsl:when>
        <xsl:otherwise>
            <xsl:choose>
                <xsl:when test="T">
                    <span class= "goog-trans-section l" transId="gadget_{$res_num}">
                    <xsl:call-template name="reformat_keyword">
                    <xsl:with-param name="orig_string" select="T"/>
                    </xsl:call-template>
                    </span>
                </xsl:when>
                <xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
            </xsl:choose>
        </xsl:otherwise>
    </xsl:choose>
  5. Apply the changes in the XSLT Stylesheet Editor

To get metadata results, you need to add the "&getfields=*" param to the search query. Search results would then look like this:

Step3 Changed title

Additional Information: See this document for more information about Advanced Customization Topics.

Versions affected: 7.2, 7.4 releases

Was this article helpful?
How can we improve it?