Message Boards Message Boards

3
|
2813 Views
|
0 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Migrating a site off the Wolfram Cloud

Posted 5 years ago

I had multiple sites on the Wolfram Cloud (still have a few) but without any compelling reason to keep them there, I moved them away. Given how slow and buggy the servers can be and how ugly the URLs were and generally less-than-convenient it is to work with I think this was definitely the right choice and will serve me well in the long run.

But migrating all those links and things isn't an entirely obvious process, so I thought I'd detail what I did to get them off the cloud. As an example, let's consider my personal website which for a long time lived here:

I decided it was high time to move it to GitHub Pages like the rest of the programming world, so I set up a repo for my site, rebuilt my content pointing to b3m2a1.github.io and deployed and, lo and behold, I had a new site:

Now the question was how to get all of my Wolfram Cloud stuff to point away from the cloud. First off, I had to figure what stuff was up there. For that I just used a little function to scrape through and find all my pages:

cloudObjs =
  Flatten@
   FixedPoint[
    {#, Flatten[CloudObjects /@ #[[-1]]]} &,
    {{CloudObject["user:b3m2a1/home"]}},
    15
    ];

Now I didn't want to have to redirect all of that. Why redirect the stylesheets and javascript and stuff after all? And even more to the point, I didn't want to had a redirect to a page that wouldn't exist in the future. So I had to figure out what I had locally that was being deployed to GitHub. To do that I just stripped the leading part of my URL and checked the file path against my local directory:

realFiles =
  Select[
   StringTrim[cloudObjs[[All, 1]], 
    "https://www.wolframcloud.com/objects/b3m2a1/tutorial/"],
   FileExistsQ@
     FileNameJoin@{"~/Documents/GitHub/b3m2a1.github.io", #} &
   ];

Then I figured why put a redirect on anything that's not HTML, so I restricted these further:

htmlPages =
  Select[realFiles, StringEndsQ[".html"]];

And then finally I had to do all my redirects:

CloudDeploy[
   HTTPRedirect[URLBuild@{"https://b3ma1.github.io", #}],
   "user:b3m2a1/home/" <> #,
   Permissions -> "Public"
   ] & /@ htmlPages;

And with one final touch to make the main redirect be to b3m2a1.github.io not b3m2a1.github.io/index.html I had my new site with all my links pointing properly:

enter image description here

And it was almost instantaneous gratification. It's so much faster, the resources all load without any glitches, and I don't have that ugly www.wolframcloud.com/obje... URL that just looks wrong.

I also did this for my Mathematica tutorial:

enter image description here

And the process was essentially the same. If you have a site on the Wolfram Cloud this is worth considering. I'm almost certain it'll make your life better.

POSTED BY: b3m2a1 ​ 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract