none
Sharepoint 2013 - Remove "Recent" from left menu

    Question

  • Hello All -

    My client has requested that she be able to remove (or hide) the "Recent" menu header from the left menu in Sharepoint 2013. This is for specified site collections/sites/pages, not farm-wide.

    So far, I've tried to do this via JQuery by adding the following code

    <script type="text/javascript">
    jQuery(document).ready(function() {
     jQuery(".ms-core-listMenu-item:contains('Recent')").parent().hide();
    });
    </script>

    via both a script web-part and via a content editor web-part (using embed code), but to no avail. I've also tried adding the code above to a .js file (without the script tags) and calling it as

    <script type="text/javascript" src="/_layouts/15/menu.remove.recent.js"></script>

    instead, but it still doesn't work.

    I've checked the page source and I can see the script is included. The "Recent" menu item however, is still there. My prefered solution would be to hide the menu item rather than remove it - I suspect removing it will probably cause issues as Sharepoint likely expects it to be there.

    There's no requirement to use JQuery - it just seemed to me to be the best way. I would also rather not edit master pages unless there's no other choice.

    Any ideas?


    sysadmin

    Thursday, September 5, 2013 4:27 PM

Answers

  • If its specific site collection why don't go to site settings >> navigation settings and remove the "Recent" heading and its links.

    Am I missing something?

     

    ---
    Rajesh | Blog

    Wednesday, September 11, 2013 3:34 AM
  • Hi xida,

    You need to reference the JQuery library, then add the code in the Content Editor Web Part in the view page (e.g. AllItems.aspx) of the Pages library, then the "Recent section" will be hidden when you access this AllItems.aspx page.

    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    jQuery(document).ready(function() {
      jQuery(".ms-core-listMenu-item:contains('Recent')").parent().hide();
    });
    </script>

    Thanks


    Daniel Yang
    TechNet Community Support

    Wednesday, September 11, 2013 3:01 AM
    Moderator

All replies

  • Hi xida,

    You need to reference the JQuery library, then add the code in the Content Editor Web Part in the view page (e.g. AllItems.aspx) of the Pages library, then the "Recent section" will be hidden when you access this AllItems.aspx page.

    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    jQuery(document).ready(function() {
      jQuery(".ms-core-listMenu-item:contains('Recent')").parent().hide();
    });
    </script>

    Thanks


    Daniel Yang
    TechNet Community Support

    Wednesday, September 11, 2013 3:01 AM
    Moderator
  • If its specific site collection why don't go to site settings >> navigation settings and remove the "Recent" heading and its links.

    Am I missing something?

     

    ---
    Rajesh | Blog

    Wednesday, September 11, 2013 3:34 AM
  • Hi -

    Thanks for the replies, sorry about my late response

    @Daniel - Thanks, I'll look in to this. However - the client wasn't aware that the 'Recent' menu was individual to each user, she wanted it removed as the thought everyone could see her recent documents. Once this was explained, she was happy to have the recent items remain on the menu. I will try out your suggestion in my DEV environment though, but at a later time.

    @Rajesh - Thanks - The issue here is that it's dynamic and will reappear. It seems the only real way to get rid of it is to hide it via a script (as above).


    sysadmin

    Wednesday, September 18, 2013 8:44 AM
  • If you want to remove it for good, create an event receiver which fires when list is added to site, then just update the navigation by deleting the "recent" item.

    public override void ListAdded(SPListEventProperties properties)
    {
    	base.ListAdded(properties);
    
    	SPWeb web = properties.Web;
    	if (web != null)
    	{
    		var title = SPUtility.GetLocalizedString("$Resources:core,category_Recent", null, web.Language);
    		SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
    		foreach (SPNavigationNode node in nodes)
    		{
    			if (node.Title.ToLower().Equals(title.ToLower()))
    			{
    				node.Delete();
    				break;
    			}
    		}
    	}
    }
    


    • Proposed as answer by Neeloj Tuesday, August 26, 2014 9:08 AM
    Tuesday, November 12, 2013 6:45 AM
  • This would be excellent but Recent does not display on the navigation settings.
    Tuesday, January 14, 2014 9:19 AM
  • This script worked for me for removing the "Recent" headings and the nodes under it in the Left navigation :

    $FindString = "Recent"
    Get-SPWebApplication "http://SharePointWeb" | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | ForEach-Object {
    $web = $_;
    write-host $web.Navigation.QuickLaunch.Count;
    for ($i = $web.Navigation.QuickLaunch.Count-1; $i -ge 0; $i--)
    {
    $node = $web.Navigation.QuickLaunch[$i];
    if($node.Title -eq $FindString){
    $node.Delete();
    write-host $node.Title;
    }
    }
    }


    Deepak_K



    • Edited by Deepak_K Wednesday, April 9, 2014 7:22 PM
    Wednesday, April 9, 2014 7:21 PM
  • No, you aren't missing something, MICROSOFT is missing something. You can delete the menu item all you want, but it will come back. Microsoft, as usual, has decided that you MUST have this feature. It would be nice to just have a checkbox somewhere to turn it on or off. But no, they decided you need to have this, and you have to write scripting to hide it.

    When will Microsoft realize that we would like to have the power to customize our sites, and stop making us jump through hoops to get around their default designs? Just because you think it's a good idea, doesn't mean you should carve it in stone.

    Wednesday, May 28, 2014 12:24 PM
  • The way i got around this is to Create a Group that has no members in it.

    Then simply set Target Audience on the Recent folder to the Group you just created.

    • Proposed as answer by Andrew Stokes Friday, August 29, 2014 2:45 PM
    Monday, August 4, 2014 12:21 AM
  • Thanks Dario that's a neat work around.  It did the trick for me :)
    Friday, August 29, 2014 2:45 PM
  • Excellent ! 

    Thanks for a clean and quick workaround !


    Saturday, September 20, 2014 3:16 AM
  • Perfect Dario. Short and sweet and no custom code. Thank you. 
    Tuesday, October 7, 2014 1:55 PM
  • Thanks Dario! That was so easy and worked perfectly.
    Sunday, January 4, 2015 12:32 PM
  • Dario, can you give some detail on how you get to these folders?  I can't seem to locate the folders so that I can turn on audience targeting.  Can you get there using the regular Admin tools?
    • Edited by Covert Rain Thursday, January 22, 2015 4:05 PM
    Thursday, January 22, 2015 4:04 PM
  • Brilliant idea! Thank you SO much!

    We don't have access to master pages on our SharePoint collection, so this was the perfect workaround.

    Tuesday, February 3, 2015 10:00 PM
  • Site Settings > Look and Feel > Navigation > Structural Navigation

    Friday, May 1, 2015 12:07 AM
  • Is there anyway to the emptygroup thing for the entire site? It seems I have to do it for every subsite.


    BNM OBG

    Monday, May 4, 2015 4:27 PM
  • That was an awesome workaround!
    Friday, June 19, 2015 3:02 PM
  • Not a good idea to use wildcards to remove stuff from quick launch. What happens if a customer decides to add a site called "My Recent stuff" when you have add the suggested code?

    If you must hack this, at least use the equality operator

    https://api.jquery.com/attribute-equals-selector/


    Anders Rask
    Twitter: http://www.twitter.com/andersrask


    • Edited by Anders Rask Wednesday, September 2, 2015 10:06 AM
    Wednesday, September 2, 2015 10:05 AM
  • @Dario.You the man. Great work around
    Thursday, October 15, 2015 10:10 AM
  • Hi Daniel,

    I think your script prevents user from creating a site called "Recent".

    I know none of these all super elegant, but I would recommend using

      jQuery("span.ms-core-listMenu-item:contains('Recent')").parent().hide();

    instead, as the system "Recent" Tab is a "Span" and actual site links are <a> tags.

    Just my two cents!
    ================================================================

    UPDATE:  This does not work well when link assigned to the Recent "Tab"

    • Edited by PCHS007 Tuesday, November 3, 2015 11:06 PM
    Tuesday, November 3, 2015 10:56 PM
  • Great suggestion!
    Wednesday, November 4, 2015 4:24 PM
  • Hi Dario, does this work for SP 365?  I cannot seem to find the AUDIENCE prompt, I only see "Web Address" and "Description"
    Thursday, February 18, 2016 4:10 PM
  • Hi Dario, your method worked great. However I have two questions.

    1. I set a empty group for the recent folder. But I'm also a site collection admin. I thought site collection admin should not be restricted in any way as far as permission goes? But the recent folder still got hidden from me? Is this normal?

    2. Anyway to apply this audience setting across the site? Or does this have to be applied on a site by site (page by page) basis?

    Thanks,

    Thursday, February 18, 2016 8:20 PM
  • Typical microsoft bullshit. Unreal. This is the future? Sharepoint is garbage. If you use it you are an idiot.

    Nobody wants this feature, so make it default. 

    Microsoft proves more every breathing moment they dont give a flying shit about decent software.  

    Wednesday, March 23, 2016 3:42 PM
  • Hi Dario, your method worked great. However I have two questions.

    1. I set a empty group for the recent folder. But I'm also a site collection admin. I thought site collection admin should not be restricted in any way as far as permission goes? But the recent folder still got hidden from me? Is this normal?

    2. Anyway to apply this audience setting across the site? Or does this have to be applied on a site by site (page by page) basis?

    Thanks,

    TravelNorth,

    1. Target audience is a different logic with permission. So a site collection will not see the "recent" folder if he is not the target audience.

    2. Target audience only "List and library", "Navigation" and "Web Parts" (ref: https://support.office.com/en-us/article/Introduction-to-targeting-content-on-a-SharePoint-site-to-specific-audiences-3009b54d-c157-4d85-ae1f-18a974b63524). For example, you have setup target audience on "recent" folder (which is a navigation) everyone not within the target audience will not able to see the "button" or "link". You don't need to change site by site or page by page.

    Wednesday, June 1, 2016 7:21 AM
  • Dario,

    Where is the Recent Folder? On my Quick Nav, the Recent name is there, but no link. Where do I go to find it to apply Target Audience settings?

    Tuesday, July 5, 2016 6:41 PM
  • Hi, you can hide using Jquery.  Add below jquery code in your file that you are loading on page load.

    $("#DeltaPlaceHolderLeftNavBar li").each((i, e) => {
    let $e = $(e);
    $e.find(".menu-item-text");
    if ($e.find(".menu-item-text").text() == "Recent") {
    $e.hide();
    }
    });

    Monday, January 23, 2017 2:55 PM
  • Worked perfectly! Short and simple. Thanks Dario!
     
    • Edited by SGarcia6 Monday, March 6, 2017 10:30 PM
    Monday, March 6, 2017 10:30 PM
  • Darron

    You want to make sure that you have the SharePoint Server Publishing Infrastructure feature turned on to see the Navigation link.

    This is a Site Collection feature. Once you activate the feature, the link in your site settings will change from:

    Quick Launch --> Navigation

    The Navigation link will be where you will find the more advanced features, for example, adding a link with a Target Audience

    Friday, July 7, 2017 1:44 PM
  • This. So much this. I dont know why there isnt a feature in SP that lets admins choose to turn off the "Recent" option from appearing. Everytime i create a list, I need to go and remove the "Recent" node from the nav. EVERY. SINGLE. TIME.
    Thursday, March 22, 2018 4:15 PM