How to use HTML helper to render a SXA component in Razor view
If you are migrating from traditional Sitecore to SXA, you may find part of your traditional component markup can be replaced with out of the box SXA component. Or if you are already using SXA you may find a need to reuse a SXA component or its Rendering Variant inside of your custom component's view. In my case, after building a custom Search Results component I realized that I can reuse one of the custom Rendering Variants I created for a Bootstrap Card markup to render search result item of my custom component. It allowed me to reuse the markup I created using Rendering Variant there by eliminating duplication of code. To render a component in your Razor view you can use the @Html.Sitecore().Rendering(path or id) helper. This works fine for rendering traditional Sitecore components. However, this helper was not built to accept the parameters required for SXA components, for e.g. the rendering variant name or id. I couldn't find any documentation on doc.sitecore.com o...