Github Pages only supports redirects via Jekyll's ruby gem, which creates static HTML files with a <meta http-equiv="refresh"
in the <head>
.
If you run a JavaScript site that uses hash fragments (aka, site.com/#!/page
) search engines may not be able to index the content. (See noddity as a blog framework that uses hash fragments but serves static files.)
Most search engines an HTML tag <meta name="fragment" content="!">
in the <head>
, which redirects to the URL and uses _escaped_fragment_
as a query parameter.
E.g., site.com/#!/page
redirects to site.com/?_escaped_fragment_=/page
which serves up static HTML.
Github Pages don't support .htaccess
rules (for good reasons), so the _escaped_fragment_
method does not work.
???
I don't have one, but I would like to find one.
I run a server with a LAMP stack, and use a .htaccess
file to provide the redirect. You can see the file here.
Github Pages (GP) doesn't support htaccess, but maybe they would be willing to support one if it were standardized in some way?
For example, GP supports a CNAME
record as a way to use your own domain to show GP content.
The important rule in the .htaccess
file is this:
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(?:[^&]*/)?([^&/]*)
RewriteRule .* "http://static.site.com/?%1"
Which would redirect requests like site.com/?_escaped_fragment_=/post
to static.site.com/post
.
How could GP standardize this redirect so that a person could offload static generation to some other site?
Perhaps search engines would support a modification to the meta tag, something like:
Which would take
site.com/#!/page
and look atstatic.site.com/path/page
for the static content to index, but still point tosite.com/#!/page
as the link on their search results page.