Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Last active January 22, 2016 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsakamoto/6645394 to your computer and use it in GitHub Desktop.
Save jsakamoto/6645394 to your computer and use it in GitHub Desktop.
my default meta tag
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<meta name="viewport" content="width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="twitter:card" content="summary">
<meta property="og:title" content="{TITLE}" />
<meta property="og:description" content="{DESCRIPTION}" />
<meta property="og:url" content="@Url.AppUrl()" />
<meta property="og:image" content="@Url.AppUrl()/Content/images/ogpimage.png" /><!-- The size of ogpimage.png is 120px x 120px. -->
<meta name="keywords" content="{KEYWORDS}" />
<meta name="description" content="{DESCRIPTION}" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="~/favicon.png" rel="icon" type="image/png" />
...
</head>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
public static class UrlHelperExtension
{
public static string AppUrl(this UrlHelper urlHelper)
{
var request = urlHelper.RequestContext.HttpContext.Request;
return request.Url.GetLeftPart(UriPartial.Scheme | UriPartial.Authority);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment