@hamelsmu I thought I’d ask this here since I imagine others will want to know as well. (And apologies if this is answered already elsewhere – In which case just point me to the answer!)
Here is some background that will make my answer easier to understand. There are different kinds of GitHub pages. The two that you most often see are:
User pages: This is when you name your repo username.github.io. A GitHub user can only have one user page. When you setup a user page by naming your repository in this special way your site is served at http(s)://<username>.github.io. Notice how there are now subpaths, like /blog at the end of your url. For a variety of reasons, fastpages does not support user pages. However, fastpages supports project pages.
Project pages are when you name your repo like any other github project, like my_repo. in this case your site will be served at (unless you’re using a custom domain): http(s)://<username>.github.io/<repository> or http(s)://<organization>.github.io/<repository> (depending on if you setup the repo in your individual GitHub account or under an organization). this is what fastpages supports.
Now, your challenge is that you need to migrate your former user site to a project site. One solution to this could be to redirect folks from your old url to your new one. I haven’t tried this myself but I found this article while searching for this just now. https://dev.to/steveblue/setup-a-redirect-on-github-pages-1ok7
It’s possible it just breaks the current automation. Perhaps will support that in the future. Had to pick one flavor to begin with and this one was a little easier to automate.
Thanks,
I implemented the redirection myself, I also wanted to make sure that all the old urls would work, so I modified the theme of the old website to redirect each page (I had the same relative url on the old and the new website):
Hello guys! My current URL is https://covid19graficos.github.io/relatorio but I would like to make the URL https://covid19graficos.github.io to work as well. Ideally I would like to remove the \relatorio from the original URL, however, @hamelsmu mentioned that the current automation will be broken. So, I assume that the best solution is to use redirects. I am very very beginner in web development. Can anyone suggest a reference or a video to help me creating this redirection idea? Probably the first step will be to create an organization page with the repository name covid19graficos.github.io. Then the next step would be to just create an index.html with the code that @zonca shared?
Thank you so much for creating this template! It makes my life so much easier to publish jupyter notebooks!
Reason not to use username .github.io - lack of automation. Maybe it good idea do all automation (convert nbs to md) on client side and than after push only deploy md to pages?
@hamelsmu
Thanks, I did read this before. I dont mind breaking the automation, since I always compile locally before publising. So was just figuring out a way around, great project tho!
@hamelsmu Revisiting the question of redirects: This FYI is optional for users who want/need to try.
It’s also possible to redirect individual pages, rather than the full blog:
Today I was able to get the plugin jekyll-redirect-from working, just by modifying _config.yml and Gemfile, and then adding the - redirect_to: <new_url> YAML front matter in my Jupyter notebook source on the ‘old’ blog, and the result is
that individual pages on my old Fastpages site like this page with the ‘devblog3’ in the url will now automatically redirect to the corresponding pages in the new blog with ‘devblog3’ suddenly changing to ‘blog’ in the URL.
(I did this because ‘devblog3’ was supposed to be temporary, but thanks to Jeremy & others a few of my posts there got shared around and some people still refer back to them, so I didn’t want to delete the links. Now everything goes to ‘blog’.)
I made a post on my experience here, but the problem was I had two blogs one that was sitting on the .github.io and then the new fastpages site at /dl-blog. To complicate matters I had already set up the custom domain name on the old site.
The easiest thing is a redirect or in my definition a forwarder. You create an index.html file in the .github.io directory and repoint it to where your fastpages repo (which should be /something) in my case it was /dl-blog.
Somehow I screwed up with so many parameters in the _config.yml and after hours of troubleshooting it, just cloned a new repo, copied all the content over, renamed the forwarder and everything was working.
Something that warned me of not doing too much custom stuff is that when things change from fastpages for an upgrade, it may not be as smooth as you would like.
Anyway, just my 2 cents.
If you’re going to use a redirect (which I also do) you should note that it’s safer to include a link in case the client doesn’t behave itself and redirect as expected. It shouldn’t really happen but it can.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url=https://joedockrill.github.io/blog/" />
<link rel="canonical" href="https://joedockrill.github.io/blog/" />
</head>
<body>
<h1>
This page has been moved to <a href="https://joedockrill.github.io/blog/">joedockrill.github.io/blog/</a>
</h1>
</body>
</html>
Normally, now it should be possible to use fastpages for GitHub Pages user/organization sites. I have created a Pull Request to adapt the setup workflow for these cases. Once it will be accepted and merged, it will be official!