Fix that GroupId check should be case insensitive, add a script to clean up the lib/bin and/or node_modules folders, and a demo about the Tenants Environment Robots feature! Check out our post for the details!
Orchard Core updates
Fixing that GroupId check should be case insensitive
If you go to a settings page in the Orchard Core admin panel that has a corresponding
DisplayDriver, the URL of the page is not case-sensitive, but the
if (context.GroupId == GroupId) check in the override of
DisplayDriver.UpdateAsync is case-sensitive. This means that you can enter two different URLs for a settings page, both of which will work, but only one of which will actually cause any updates to be applied when the form is submitted. When you searched for that line of code across the Orchard Core 1.5 solution, you find it in 16 drivers, so you would expect this issue affects all of them.
The fix here is the
GroupId comparison in
DisplayDriver.UpdateAsync should be case-insensitive. If the page loads correctly for a given URL, submitting the page should work as expected rather than mysteriously failing to update the settings. Here you can see the changes in updating the checks on the drivers.
Add a script to clean up the lib/bin and/or node_modules folders
Sometimes it is useful to be able to use the command line to remove all lib and bin folders from every project using the command line. It's even more useful to be able to remove all node_modules from every project using the command line. From now on, if you want to remove the bin and lib folder from all the projects, you can run npm run cleanup. If you want to remove all node_modules folders from all the projects, you can run npm run cleanup node_modules. If you want to clean up bin, lib, and node_modules, you can run npm run cleanup all.
Lombiq Hosting - Tenants Environment Robots for Orchard Core
The feature that we will check out today is called Lombiq Hosting - Tenants Environment Robots, which is a module that prevents search bots from indexing non-production environments. Let's say you are hosting sites on a staging environment, and we usually want to prevent search bots from indexing the staging environment. And if we enable this feature, this will exactly do that. Let's quickly see it in action!
This module is included in Lombiq's Open-Source Orchard Core Extensions solution so we will build this solution. Now we can navigate to Configuration -> Features and find the feature called Lombiq Hosting - Tenants - Environment Robots to enable it. Now let's see how it works! The module works by adding an X-Robots-Tag header with the value noindex, nofollow to the HTTP response of non-production apps. This instructs search engines not to index or follow the links on these pages. Additionally, the module also adds a
<meta name="robots" content="noindex, nofollow"> tag to the HTML head of non-production apps for the same purpose. To try this out, let's navigate and open up the homepage of our site, for example, and open up the DevTools window of Google Chrome (or use any other browser, of course).
You will notice two things here. First of all, you will find the new meta tag if you click on the Elements tab, which contains the
noindex, nofollow values.
Now, let's navigate to the Network tab of the DevTools window and find the Response Headers section of the currently loaded page. Here you will notice that we have a header with the following value:
X-Robots-Tag: noindex, nofollow.
And you can also override this option by setting it to true or false in the appsettings.json file under the
Lombiq_Hosting_Tenants_EnvironmentRobots:EnvironmentRobotsOptions:IsProduction section, as the readme file of the module mentions.
And as always, if you would like to know more about this feature head to YouTube for a recording!
News from the community
Orchard Dojo Newsletter
Lombiq's Orchard Dojo Newsletter has 465 subscribers! We have started this newsletter to inform the community around Orchard of the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.
Do you know of other Orchard enthusiasts who would like to read our weekly articles? Tell them to subscribe here!