Hiding links for users without access


I am trying to figure out how to hide links in the Top Bar navigation for users that do not have access to something. I find it strange that I don't get many search results in Google that even discuss it.


My structure is Hub Site with a Communication Site that has several subsites. The top Bar navigation (starting at the Hub) contains links to the various subsites. Not all users have access to these sites but the links still show up for them. After doing a little research, these links are in fact hard coded, which is a big part of the problem.


My tenant does not yet have the Audience Targeting option for navigation which appears to be rolling out soon. At this point, I have not enabled the SharePoint Server Publishing Infrastructure at the Communication site. I'm not entirely sure I want to do that based on what I've read. By enabling this feature, would it give me options to hide those links?


I'm really new to SP and not sure if I want to complicate matters by enabling SharePoint Server Publishing Infrastructure. Maybe I need this and just don't realize it yet.


14 Replies
best response confirmed by alandarr (Contributor)



Hi, The feature you are looking for is called security trimming, and you are correct in that if you want to make use of this then you will need to enable the publishing feature.  So it's a bit of a trade off i'm afraid.  You can read more about the options here - 

The other way is a custom navigation implemented through a SPFx the way not a fan here of enabling publishing on modern sites

@Juan Carlos González Martín 


Totally agree, also not a fan of doing so.

@Juan Carlos González MartínWould you mind saying a bit more about why you don't care for publishing on Modern sites?  Thanks! 


@Juan Carlos González Martín @PeterRising 

Thanks for the info. I am also wondering, along with @Cindy Zalme why you would not suggest the Publishing option. I am hesitant to enable it, but I may be missing something if I don't.



I cannot speak for @Juan Carlos González Martín, but my own personal feeling is that the publishing features have always been available with the classic SP sites in mind as opposed to the modern ones.  Initially, the publishing features were made available in modern sites with a view to migrating older  classic sites into a modern site in a sort of coexistence. They were never really meant for modern sites though, and modern sites have way more options to look professional out of the box without having to rely on the publishing features.  


I also feel that (personal opinion again), that as long as users cannot access content they don't have permissions for, then all is good. Security trimming for me is a nice to have, not really a make or break feature though. :smile:

Mainly because Publishing feature is a "legacy" feature pre-modern. Enabling the feature you introduce a lot of stuff you need:
- A new document library that can be confusing for your users
- The pages document library that does not support (to my knowledge) modern pages
- A bunch of lists
- New SharePoint Groups
So yes, you can better manage the navigation but also at the cost of adding many staff that does not make sense on modern

@PeterRising @Juan Carlos González Martín 

Thank you both for that insight. I didn't realize that it was really a sort of migration feature. But there is still the issue of hiding menu items. For now, a user can see the link but they are presented with the "ask for permission to access this site" message and a way to send a note to the owner of a site.

I guess the new "Audience Targeting" feature will be the answer. Evidently it's rolling out already, but I have not seen it in our tennant yet and I am not sure we will. I was aware of it prior to my question, but really wanted opinions on the Publishing option pros and cons. Thank you both for your input! I'm glad I asked before enabling the Publishing feature!

Audience Targeting was recently discussed here: 

And here's a link with more details: 

@PeterRisingReally appreciate your taking the time to explain!  

@Juan Carlos González MartínThanks for taking the time to provide feedback! 

@alandarr Depending on your requirements, one option could be to create a new site page and add the "Sites" web part. It can display sites attached to the hub and it is also security trimmed. Just link this page in your hub. 

Thanks @Martin Coupal.

I will look into that. Sometimes you just have to look at something from a different perspective!

@PeterRising it's a real shame that Office 365 groups don't take part in security trimming :( My client has a blend of classic sites and modern Office 365 groups. They are moving towards the later exclusively but the fact that the link now always appears in quick links is a step backwards.



>The other way is a custom navigation implemented through a SPFx extension...

Any reference material on these? Never used them.