Forum Discussion

jeromedb's avatar
jeromedb
Contributor
11 years ago

Can I add a last updated or modified date to a page metatag?

Hi guys,

 

I'm working with a sitewide enterprise internal search engine which makes extensive use of custom metadata tags, such as <meta name="product_sku" content="abc123" /> for filtering, categorising, ranking and displaying search results.

 

We intend on indexing category, board, article, blog and thread pages (not messages), and would like to capture the date of the last modification/update to each via a custom metatag added to the page. This will allow us to not only display a "last updated" date within the global search results, but rank content according to recency.

 

So my question is twofold – is the last modified date readily available across category, board, article, blog and thread pages, and if so, can it be added to a metatag such as <meta name="last_updated" content="16-10-2013" />?

 

Much appreciated!

 

Cheers, Jez

  • PaoloT's avatar
    PaoloT
    11 years ago

    Hi Jerome,

     

    as I mentioned you should be able to determine the date of the last change for these pages via the REST API looking at the time elements included in the responses. I am not sure around the effort required in building the XML feed - maybe you could look into the Lithium Studio Endpoints to generate the required data (with the rest calls) and pack it in the response format which can then be consumed by your tool.

     

    I have a feeling that implementing the logic that adds the meta tags directly to the pages may be quicker, but it's difficult to tell without all the details.

     

    In this case - it could be best to speak with your Lithium Manager and see if it's possible to arrange a consultancy on your specific integration issue.

     

    Kind Regards,

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    Hi Jez,

    just to be clear - what do you define as "date of last modification / update" for each element?

    For a category, board, or thread I would think that could be the date of the latest post written (in which case you can get via REST - see for example http://lithosphere.lithium.com/restapi/vc/boards/id/studio/posts/recent for the latest post on the Developer forum on the Lithosphere - see post_time or last_edit_time ).

    You could use similar approaches for blog articles and threads (taking the last_edit_time of the root topic) - always via REST.

    You could then include this logic in your community wrapper to generate the appropriate tag.

    Hope that helps.
    • jeromedb's avatar
      jeromedb
      Contributor

      Hey Paolo,

       

      Really appreciate your quick reply :)

       

      In terms of last modified, I'm looking for the date that any given board or thread was last updated. From what I can see a thread is made up of multiple messages, each ith their own date - I'm only interested in the latest date that any message within a thread was updated.

       

      As an alternative, the search engine I'm working with is capable of taking an xml feed, which might contain the title, url, and the above mentioned date for all thread, board and category pages. I initially explored the sitemap.xml, however it did not include all of the items I was looking for.

       

      Might what I'm trying to do be more effciently done as an xml feed with appropriate tags, rather than me crawl the site organicalluy and picking up the date in a metatag?

       

      Cheers, Jez

      • jeromedb's avatar
        jeromedb
        Contributor

        Hey Paolo,

         

        I'm thinking an xml feed is perhaps the best approach for me to capture this information - do we do this via the REST API?

         

        Cheers, Jez

         

  • Thanks Jason - I'll chat with Starhub around the update below and come back to you.

    J

    • jeromedb's avatar
      jeromedb
      Contributor

       

      Hey Jason,

       

      We've followed the freemarker code example, however we're having some issues dynamically getting the topic id - below is some feedback from the developer that is working across this, would really appreciate any assistance you can provide.

       

      On the timestamp component we're fine.

       

      Cheers, Jez

       

      ---------

       

      the example given in Lithium is this one below, which is throwing an Exception

      <#assign topic_id = page.context.thread.topicMessage.uniqueid />

       

      To test if the rest of the code is working, I hard coded the "topic_id" as below

      <#assign topic_id = 713 />

      and it worked.

       

      But you might notice, it always display the same time. So we need to dynamically get the "topic_id"

       

      Below is the full Code

      <#if page.name='ForumTopicPage'>

      <#assign topic_id = page.context.thread.topicMessage.uniqueid />

      <#assign last_edit_time = restadmin("/messages/id/${topic_id}/last_edit_time").value!"" />

      <meta name = "last_updated" content="${last_edit_time}" >

      </#if>  

      • JasonL's avatar
        JasonL
        Lithium Alumni (Retired)

        Hi Jez,

        My apologies ... typo ...  it should be uid:

         

        <#if page.name='ForumTopicPage'>
        <#assign topic_id = page.context.thread.topicMessage.uid />
        <#assign last_edit_time = restadmin("/messages/id/${topic_id}/last_edit_time").value!"" />
        <meta name = "last_updated" content="${last_edit_time}" >
        </#if>  

         i just tried it out on test env, seems to be working 

  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    Hi Jerome
    Really sorry, I'm afraid this is getting a little deep and it would be best to engage Lithium Services to scope out the full requirements, properly advise or even implement the freemarker coding.

    Can you kindly ask StarHub to reach out to their Lithium Account Executive for a Services quote?