0

I'm trying to migrate my site from Blogger to Hakyll (which I'll then deploy to Github pages), but I don't want all old links to break. Also, my old posts were all in blog.domain.com/, whereas now they'll be in domain.com/posts/. What's more, the URLs in Blogger only include the month and year, whereas in Hakyll they're including the day as well, which means I'll almost certainly have to do things manually. A quick Google search has not turned up answers, and I don't have enough knowledge of how-to-write-websites to solve my own problem.

Example of the format I'm trying to redirect from

blog.domain.com/2015/09/title.html

Which I would like to map to

domain.com/posts/2015-09-08-title.html

EDIT: I found something that ought to work, but doesn't. After setting up my redirects exactly as in the example file, I get one of two errors:

1) unexpected character \n

OR

2) expected ListField but got StringField

gallabytes
  • 267
  • 1
  • 9
  • 1
    The redirection must be set up in your old blog, and not in the new one. Even if your old blog were built with Hakyll, 301 redirects require either a dynamic site or server configuration adjustments, and so Hakyll wouldn't be involved anyway. According to [the accepted answer of this question](http://stackoverflow.com/questions/24795465/use-301-redirect-in-google-blogger-blogspot), it is possible to set up redirects using the Blogger dashboard. – duplode Sep 16 '15 at 22:04
  • The Blogger dashboard redirect options won't work - they can only redirect from blog.domain.com/FROM to blog.domain.com/TO. I need blog.domain.com/FROM to domain.com/posts/TO. If 301 redirects won't work, what could I use in their place? – gallabytes Sep 17 '15 at 01:21
  • I could also just have the redirects be from domain.com/FROM to domain.com/TO and change the host records for blog.domain.com to redirect to domain.com, if that would make a difference. I'm hoping to abandon Blogger entirely, so a solution that relies on Blogger isn't going to cut it. – gallabytes Sep 17 '15 at 01:31
  • 1
    (1) Ouch, I should have suspected that. There are a few tricks of dubious taste you might do, such as using JavaScript or meta-refresh in the source pages. See [this question](http://stackoverflow.com/q/9276817/2751851). – duplode Sep 17 '15 at 01:40
  • 1
    (2) Your second comment sounds like a good plan. You will have to confirm whether it actually works, bur I think it is likely to. (3) That link in your edited question isn't going to help -- it is setting up redirects from a Hakyll site in which you can change the `.htaccess` file in your directory within the server. – duplode Sep 17 '15 at 01:46
  • (3) Oy. I'll look into alternatives to Github pages then, as a Javascript redirect is not quite as desirable. The interesting thing is that it still doesn't work even when I'm just using localhost. – gallabytes Sep 17 '15 at 04:38
  • 1
    You will have the same problem in GitHub Pages or elsewhere, as the redirects will happen at Blogger no matter what. The best solution would definitely be changing the host records, as you say in the second comment, if that is actually possible in your case. – duplode Sep 17 '15 at 05:03

1 Answers1

1

Solving this problem turned out to take a few different tricks.

Part of it may be NameCheap specific, but all I had to do was set up a redirect from blog.domain.com to domain.com, as in this tutorial.

The other part was getting Hakyll to do the right thing for routing. After dealing with a peculiarity of the gsubRoutes function, this turned out to be fairly simple (code here).

gallabytes
  • 267
  • 1
  • 9