I apologize in advance if I'm not summarizing the ask correctly but I'm not too familiar with this so bear with me.
We are on a Umbraco Cloud v8 site and use a contentment data list to specify our Robots SEO options for any given page on the website to be used as the meta robots content. It's a user defined checkbox list to allow our content editors to select from No Index, No Follow, etc. If no value is selected than index it the default I believe.
For the various sitemap XML cshtml template files I'm trying to REMOVE any pages that are marked as no index.
So for the template file for the XML sitemap page I have the following query to get the pages I need (in this case it's an XML template just for our press releases)
var newsselection = Umbraco.Content(Guid.Parse("xxxx-xxxxx-xxxxx(actual guid here)"))
.DescendantsOfType("PressRelease")
.Where(x => x.IsVisible());
I guess my question is, can I add another where statement here which would not pull in pages that are listed as no index? I have tried a couple different ways but I'm not sure of the syntax to use here. We used to have a boolean option for hide from XML sitemap and that was easy just using:
The structure has been updated to use the contentment data list but I'm just not familiar with how to work with it. I'm hoping it's a simple syntax I can use, any ideas? Thank you in advance!!!
For the Data List configuration you have (user-defined data-source with a checkbox-list), the C# value type would be a List<string>, so you could try something like this...
Thanks Lee!
That looks like it would make sense to me, but I get the old "Object reference not set to an instance of an object." when I try that. Not sure what's up
Hi Lee,
Just a quick update on my end. Our data set had some items that had null or empty values on that data set so that was causing the error. For now I've updated the query to account for that and it's working great. Thanks again Lee
Filtering based on contentment Data List
I apologize in advance if I'm not summarizing the ask correctly but I'm not too familiar with this so bear with me.
We are on a Umbraco Cloud v8 site and use a contentment data list to specify our Robots SEO options for any given page on the website to be used as the meta robots content. It's a user defined checkbox list to allow our content editors to select from No Index, No Follow, etc. If no value is selected than index it the default I believe.
For the various sitemap XML cshtml template files I'm trying to REMOVE any pages that are marked as no index.
So for the template file for the XML sitemap page I have the following query to get the pages I need (in this case it's an XML template just for our press releases)
I guess my question is, can I add another where statement here which would not pull in pages that are listed as no index? I have tried a couple different ways but I'm not sure of the syntax to use here. We used to have a boolean option for hide from XML sitemap and that was easy just using:
The structure has been updated to use the contentment data list but I'm just not familiar with how to work with it. I'm hoping it's a simple syntax I can use, any ideas? Thank you in advance!!!
Hi Brian,
For the Data List configuration you have (user-defined data-source with a checkbox-list), the C# value type would be a
List<string>
, so you could try something like this...I hope this helps.
Cheers,
- Lee
Thanks Lee! That looks like it would make sense to me, but I get the old "Object reference not set to an instance of an object." when I try that. Not sure what's up
Hi Lee, Just a quick update on my end. Our data set had some items that had null or empty values on that data set so that was causing the error. For now I've updated the query to account for that and it's working great. Thanks again Lee
Super, glad that you got it working! 👍
is working on a reply...