Skip to content

Instantly share code, notes, and snippets.

View alindgren's full-sized avatar
💭
I may be slow to respond.

Alex Lindgren alindgren

💭
I may be slow to respond.
View GitHub Profile
@alindgren
alindgren / Readme.md
Created November 1, 2016 21:12
Canonical domain redirect for Umbraco Cloud sites

Sebastiaan Janssen has stated that content deploys might not work on Umbraco Cloud if you redirect /umbraco/*.

@alindgren
alindgren / web.config
Created September 29, 2016 15:37
Canonical Domain Redirect
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
</conditions>
@alindgren
alindgren / ContentExtensions.cs
Last active October 11, 2017 17:30
Umbraco Content SetValueByPreValue and SetValuesByPreValues extension methods
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
namespace My.Umbraco.Extensions
{
public static class ContentExtensions
{
/// <summary>
/// Sets the value of a property to the PreValue ID for a given preValue.
@alindgren
alindgren / Web.live.xdt.config
Created April 21, 2016 15:58
HTTP to HTTPS redirect rule config transform
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer xdt:Transform="InsertIfMissing">
<rewrite xdt:Transform="InsertIfMissing">
<rules xdt:Transform="InsertIfMissing">
<rule name="HTTP to HTTPS redirect" xdt:Locator="Match(name)" xdt:Transform="RemoveAll"/>
<rule name="HTTP to HTTPS redirect" stopProcessing="true" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing">
@alindgren
alindgren / MultilingualUrlProvider.cs
Created August 27, 2015 16:03
UrlProvider for generating multilingual URLs in 1:1 multilingual Umbraco sites - see http://www.alexlindgren.com/archive/building-multilingual-sites-in-umbraco-with-vorto-part-2/
using System;
using System.Collections.Generic;
using Umbraco.Web.Routing;
/// <summary>
/// MultilingualUrlProvider
/// </summary>
public class MultilingualUrlProvider : IUrlProvider
{
@alindgren
alindgren / MultilingualContentFinder.cs
Last active August 13, 2018 15:24
ContentFinder for multilingual sites in Umbraco
using System;
using System.Globalization;
using System.Web;
using Umbraco.Web.Routing;
using Umbraco.Core;
public class MultilingualContentFinder : IContentFinder
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
@alindgren
alindgren / XMLSitemap.cshtml
Last active May 15, 2020 17:42
XML sitemap for Umbraco 7 (based on Cultiv Search Engine Sitemap package). See http://www.alexlindgren.com/archive/dynamically-generated-xml-sitemaps-with-umbraco-7/
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Linq;
@{
Layout = null;
Response.ContentType = "text/xml";
}<?xml version='1.0' encoding='UTF-8' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@ListChildNodes(Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1))
@alindgren
alindgren / Basic Page template (dynamic)
Created September 13, 2014 03:29
Simple Umbraco demo for "Site Building with Umbraco 7" at Code Camp NYC 2014
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
}<!DOCTYPE HTML>
<html>
<head>
<title></title>
<link rel="stylesheet" href="/css/style.css" />
</head>
<body>