Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

User / Organization Pages custom domain affects all project pages URL #547

Open
sergeylukin opened this issue Jan 11, 2016 · 22 comments
Open
Labels

Comments

@sergeylukin
Copy link

Hi,

Currently, as far as I'm concerned having User Pages repository with CNAME file containing custom domain prevents one from having Project Pages repository with gh-pages branch that could be accessible via http(s)://<username>.github.io/projectname without being redirected to http://<custom domain>/projectname. I believe that having an option to disable that redirect on Project Pages repository basis would be awesome.

Here is my reasoning. I'm hosting my personal website with my User Pages repository via custom domain. However, when building an experiment / game / little project and hosting it with Github Project Pages I'm adding another dependency on my custom domain and if, for some reason, I will lose control over my custom domain in the future, all my experiments / games / little projects / whatever else hosted with Github Pages will not be accessible via indexed / promoted / remembered / written down / bookmarked URLs. However, if they were initially created with "redirect" option turned off and promoted and known to crawlers under location of type http(s)://username.github.io/projectname they would not be affected by me losing / deprecating / changing custom domain.

The only workaround I can think of right now is creating a separate User / Organization for my personal website repository while keeping the rest of my projects repositories in my current account.

Actually already today separating my personal website custom domain from my other projects hosted with Project Pages would require going over every project URL and setting up a proper 301 redirect from custom domain subdirectory to https://<username>.github.io/projectname to prevent existing links spread among the Internet from becoming obsolete and to avoid SEO troubles for custom domain because I have them all indexed for a while. So it's clear to me that there should be at least an option to break tight dependency between User / Organization Pages custom domain and Project Pages URLs. Not to mention, I'm all against that dependency at first place.

Details on how custom domain work in GH pages today: https://help.github.com/articles/about-custom-domains-for-github-pages-sites/

@sh78
Copy link

sh78 commented Mar 15, 2016

Just encountered the same issue.

I've had a personal jekyll blog hosted on gh pages with a custom domain name. While working on a chrome extension, I thought "oh cool, just init a gh-pages branch in the project repo and push that up for a quick site". Then realized that username.github.io/projectname redirects to personalsite.com/projectname with a lovely 404.

For now I've created a new organization specifically for the project AND a separate repo so that with the site source so it can be used as an org page as opposed to a project page - projectname.github.io instead of projectname.github.io/projectname.

Annoying but it works. Would be cool have more control over this from the GH side of things.

@cben
Copy link

cben commented May 19, 2016

Asked "contact a human" to clarify https://help.github.com/articles/custom-domain-redirects-for-github-pages-sites/, got detailed answers (bold mine):

Will this redirect even work? I'd expect user.example.com/* to only resolve user/user.github.io content? Does user.example.com/projectname automagically serve user/projectname gh-pages content?

Yep the user.exmaple.com/projectname will automagically serve user/projectname gh-pages content.

What if user/user.github.io happens to contain a projectname/ directory?

This question doesn't have a super clear answer I'm afraid. It should still direct to your project site but I've seen some people have issues where it 404's

Can it be disabled? I now have no user page, only project pages, and I'd prefer project pages to keep their github.io canonical URL even if I create a user page with vanity domain in the future.

I'm afraid this can't be disabled. If you have a CNAME file in a User pages site you other project pages will redirect to this Url. You can override it by adding a different CNAME to your project page though or just create another Project site to act as your user page.

What if both user page and project page have CNAME files? Which redirect wins?

If you have a different CNAME in your project page then do redirect occurs. User page will be redirected to the CNAME in the user repo and the project page will be redirected to the CNAME in your project repo.

What if project page has CNAME and there is no user page (or one with no CNAME)? This redirects to project's CNAME, right?

Yep, correct!

@sergeylukin
Copy link
Author

Thanks @cben, very informative. I've tried adding a CNAME to a project pages site gh-pages branch and it doesn't seem to override the redirect to user pages CNAME. I've tried multiple values for project pages CNAME (btw unfortunately <username>.github.io/com in CNAME is not allowed, otherwise it would just fix the problem).

Here is the project pages CNAME:

https://github.com/sergeylukin/css-pyramid-infographic/blob/gh-pages/CNAME

and here is the user pages site CNAME:

https://github.com/sergeylukin/sergeylukin.github.com/blob/master/CNAME

Still, http://sergeylukin.github.io/css-pyramid-infographic/ is redirected to http://sergeylukin.com/css-pyramid-infographic/

@BasiiSania
Copy link

At this moment,
if you want to have custom domain for some Project Pages, and you have created User / Organization Pages,
then you must to add any (temporary) custom domain for your User / Organization Pages, because it activates the custom domain for all your repo's Pages.

@deevus
Copy link

deevus commented Aug 30, 2016

@BasiiSania I don't really understand the solution

@danbovey
Copy link

danbovey commented Nov 19, 2016

I think GitHub added a new section to fix this.

image

I'm not sure whether it was changing the CNAME of my user.github.io repo temporarily to the other custom domain or switching the domain's NS to CloudFlare (free tier) - but give those a try and it's totally possible.

Also, if you set CloudFlare to Full SSL, you can get HTTPS on the custom domain, so it also solves #156

@thecristen
Copy link

thecristen commented Feb 11, 2017

That won't let us get a <username>.github.io/<project> URL that we want.
Just chiming in to say I'd also love a solution to this that doesn't involve the overhead of creating N separate organizations.

@julianofischer
Copy link

Same issue here.

@bntzio
Copy link

bntzio commented Mar 16, 2017

So as far as I know, it's not possible to have a User page with a custom domain (let's say... user.com) and various Project pages with custom domains (like... project1.com, projectxyz.com and so on).

Am I right?

@sergeylukin
Copy link
Author

@bntzio that's right as far as I'm concerned. This issue is about having both custom domain for username.gthub.io repo and other repos that are available via project.github.io without being redirected to custom domain associated with username.github.io repo. Hope that helps

@bntzio
Copy link

bntzio commented Mar 17, 2017

@sergeylukin oh alright, thanks! so the only option available for the moment is to create an organization page 😪

@rodrimaia
Copy link

rodrimaia commented Apr 6, 2017

@sergeylukin still unresolved, right?

have you got any success with the project's CNAME approach?

@cedricium
Copy link

cedricium commented Nov 30, 2017

@rodrigomaia17 I'm not sure if something has changed but I was able to successfully add a custom domain to a project of mine with using a CNAME while also having a custom domain for my user account.

Custom User domain: http://cedricamaya.me
Custom project domain: http://medium-bookmarklets.com

http://cedricamaya.me/medium-bookmarklets will successfully redirect to http://medium-bookmarklets.com. I had reached out to GitHub support and this is how was their response:

Hi Cedric,

    "Is it possible to give "cedricium.github.io/project" (which will redirect to 
"cedricamaya.me/project") it's own custom domain, such as "project.com"? From what I read
online, it looks like it's not possible if the user account has a custom domain already set."

Thanks for writing in! It's absolutely possible for your Project Pages site to have a different custom 
domain than your User Pages site. We handle all the routing for you on our end. The way you'll set
this up is virtually the same way you've set up the custom domain on your User Pages site.

    Add your custom domain for your GitHub Pages site to your repository
    Create an A-record in your domain's DNS settings with a hostname of @ pointed to 192.30.252.153
    Create a second A-record in your domain's DNS settings with a hostname of @ pointed to 192.30.252.154
    (Optional) Create a CNAME record in your domain's DNS settings with the subdomain www pointed to cedricium.github.io

More information on steps 2-4 can be found here:

https://help.github.com/articles/setting-up-an-apex-domain-and-www-subdomain

@dtolb
Copy link

dtolb commented Nov 30, 2017

Something changed, b/c it broke my sites :(

@sdhutchins
Copy link

@dtolb @bntzio @rodrigomaia17 @sergeylukin @julianofischer
It's counter-intuitive a bit. Check out http://zararah.net/blog/2015/12/27/redirecting-project-page-domain/

I have it working though. http://www.shauritaturns30.com/ & http://www.shauritahutchins.com/

This is what my namecheap setup looks like.

image

@saintplay
Copy link

Didn't try the CNAME/ALIAS solution, but here is mine

I migrate my http(s)://<username>.github.io to netlify and use a custom domain there.

Doing this I gained a lot of flexibility on deploying the codebase
My other projects should be fine into Github Pages

boatrite pushed a commit to tenforwardconsulting/tenforwardconsulting.github.io that referenced this issue Mar 5, 2018
@mfedatto
Copy link

I found a reasonable fix.

The user page only works as user page if the repository and the domain has the same name. So i changed my mfedatto.com repo to mfedatto and my custom domain for mfedatto.com changed from usor to project. This way my sameness.js pages stoped redirecting from mfedatto.github.io/sameness.js (with 404) and came back working on github.io.

@adamk33n3r
Copy link

@saintplay thanks for showing my netlify. It's pretty sweet!

@piranna
Copy link

piranna commented Mar 25, 2020

I'm not using a custom domain anywhere, but I'm having the same issues, I had my personal web page in user.github.io, and I created a gh-pages project on user.github.io/project but instead of showing me the project content I get a 404 from my personal web site. Any idea?

@olivervorasai
Copy link

olivervorasai commented Sep 18, 2020

Here is how I fixed this issue for myself:

The Problem

  1. Have portfolio repository at https://github.com/username/username.github.io
  2. https://github.com/username/username.github.io uses custom domain at www.username.com
  3. Created another project at https://github.com/username/my-new-project
  4. Create gh-pages branch so Github Pages will host it
  5. my-new-project should be accessible at https://username.github.io/my-new-project/
  6. https://username.github.io/my-new-project/ it is automatically redirected to www.username.com/my-new-project and causes 404.

The Solution

  1. Rename the https://github.com/username/username.github.io repository to https://github.com/username/username-something
  2. https://github.com/username/my-new-project should now be available at https://username.github.io/my-new-project/
  3. www.username.com is still working, subsequent projects should get standard Github Pages urls without custom domains.

@emmahsax
Copy link

I still think the best solution would be an option in the GH Pages settings of a project page to not redirect the domain of a project page.

This way, users would have a choice of having username.github.io/project-page redirect to www.customdomain.com/project-page or having it stay where it is. It's frustrating to me that we even need to find an alternative solution at all.

@Ark-kun
Copy link

Ark-kun commented Aug 29, 2021

I have to jump through so many hoops because of the inability to disable the redirect.

The redirect makes my users permanently lose access to their data.

I have built a client-side progressive web app and published it using GitHub Pages: https://cloud-pipelines.github.io/pipeline-editor/
The user create ML pipelines using my app and they're stored in user's local storage (IndexedDB).

Recently I've bought a domain name to use for the app: https://cloud-pipelines.net/

However when I configure the GitHub Pages to use the custom domain, the original address (https://cloud-pipelines.github.io/pipeline-editor/) becomes inaccessible.
This prevents any of my users from accessing their data which is stored for the cloud-pipelines.github.io origin.

I wish I could disable the redirect to the custom domain in the settings.

Being able to add URL parameter like ?disable_custom_domain_redirect=true would have solved some of my problems as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests