Can I have GitHub automatically redirect from GitHub repo view to GitHub Pages? - github

In a recent publication, I included a link to the GitHub repository for the code.
https://github.com/martinkrz/posepi1
This link is now in the literature, so I cannot easily change it. I'm wondering whether there's some way to have requests to the repo page (I can't find anything on this) be automatically forwarded to the GitHub Page for the project, which is at
https://martinkrz.github.io/posepi1/
Again, I need a redirect by GitHub.com because I'm practically stuck with the https://github.com/martinkrz/posepi1 link in the published literature.

No, this isn't possible. If it were, it wouldn't be possible for anyone to view the repository's overview page anymore, which would make doing common tasks difficult.
You could try updating your repository README to point to the place you'd like people to go, but that's the extent of the changes you can make.

This is not possible. You cannot (and to be honest nobody should) change or create self-executing code on your GitHub repository.
And thus, you cannot redirect users.
But you can put the GitHub Pages link into the description of the repository and/or add it as a link in the README.md
The link could be
Click here to see the code in action!
or something like that

Related

I'm new to github and I can't get my repositories on github pages

I'm new, reaaaally new to github, not familiar at all, just created an account (by watching one old youtube tutorial). And this is my first time here too. Also, english isn't my first language, so I'm sorry for any mistakes.
I'm using the desktop GitHub, I'm not using Git right now (but also the tutorial guy wasn't and it worked easily) and pushing my local repositories to my online github, and it worked. There are four repos and all of them are public. Yet, when I go to my username.github.io there is nothing, it doesn't exist, that's one thing to fix.
Do I have to create some file? I don't understand, there are youtube videos that say you have to choose a theme, but it's been updated I guess because the website it's not like that anymore, and it doesn't show me themes or anything like that.
I've seen a lot of youtube videos and done exactly what they have done, i've read the github guidelines but i think they are confusing, but i tried a lot of different things. If it makes any difference, my repositories only have like .html and css files (plus the images, fonts, html and css stuff). I don't know anything other than hmtl and css yet, not even javascript, so that's it.
So I don't know how to proceed, I've extinguished my completly amateur resources by doind this post, and I'm learning by myself so I have no one to help me here. Also, since I've never had any contact with github, im just "github dumb", I don't know how branchs work, I'm sorry, I know what a branch is, but somehow that plataform makes it hard.
Anyway, I want to know why my username.github.io doesn't work...
Any help, please? :')
First, create a github repository of <username>.github.io and put your html/css files there. Then go to the repository settings and find the "pages" settings at the left.
In the source, select "deploy from branch" and select your main branch and select the root directory and click save.
That's it, your repository will be published to github pages and you can see the url at the top of the page.
I have attached a screenshot if it is difficult to follow.
The same information can be found here.

Gh-pages not displaying the right thing

I'm having some issues with getting the proper page to display. I've looked up different answers and they don't seem to be working for me.
https://github.com/samus94/portfolio2.1
Please let me know what I've done wrong here.
It was displaying the readme before, and I think it still is.
First, You've posted a link to your GitHub repository, not your GitHub Page. The address for GitHub pages always looks like https://<yourname>.github.io/<reponame>.
To get this URL you can go into the settings for your repo and find the GitHub Pages section. Make sure you have GitHub Pages enabled, then look for the URL your site is published at.
Finally, GitHub Pages requires your repository have a very specific structure. It expects there to be an index.html file at the root of the repository. This means you have to either move everything in your /src directory to the root, or move the index.html and update the URLs to your javascript and CSS.
All of these requirements are outlined clearly in the GitHub Pages documentation.
Deploying static HTML + CSS + JS sites (NO jekyll) to Github Pages,
using Github Actions was harder than I though.
Theres is very few quality documentation about this specific topic, except this one:
Steps overview:
Setup a custom action in github
Push changes and the action executes automatically
Your page is deployed to github pages
One important thing: I had no need of changing any property in the yml; don't worry about customizations.

Github: display the wiki home on a repository front page

I recently created a global wiki for my company in a Github repo. It's an empty repository which I created just to use its wiki.
My problem: on the front page of this wiki repo, the Readme is displayed. And this Readme is empty, except for a link to the wiki's home.
I want to display this home on the front page of the repo. Is it possible?
Probably is better to use https://pages.github.com/ you could even go further and use hugo, in long term could be easy to maintain since you just keep track of all your articles/posts within a repo.
Regarding your question probably a redirect from the main repo to the wiki may work, check the docs for more info: https://help.github.com/categories/github-pages-basics/
With a redirect, I mean that you will need to have an index.html redirecting to the wiki URL.

Github fork and edit button from an external site

Github has the very useful Fork this project and edit the file button:
I'd like to replicate the functionality on my own site. I want users to be able to click the button, and immediately be sent to Github, fork the project, and be sent to their forked repo's version of the file in an editable textbox. Click the edit button here for an example of the functionality I am looking for.
I know that I can provide links to fork my repo from an external site like so:
https://github.com/user/repo/fork
So I tried doing this, but it did not work:
https://github.com/user/repo/fork/path/to/file
Is it possible to create a link or button in an external site which will fork and edit a file in Github?
Edit
I understand that it is impossible (and a bad idea) to force users to fork a repo (see #sircapsalot's answer). However, I don't necessarily need users to be forced to fork the repo. I would settle for functionality which asks the user if they want to fork, and if they say yes, redirects them to their forked repo's version of the file in an editable textbox.
The URL feature you're looking for is edit rather than fork:
https://github.com/user/repo/edit/path/to/file
This will prompt the user to fork the repo if they haven't and then open the file in edit mode in their fork.
You cannot force a user to fork a repository. That link there is built into GitHub, so it's inherently "trusted" (same domain).
The best you can do, is do what GitHub Badges does and just direct the user to https://github.com/user/repo/fork. But you cannot force the user to fork.
An example of why this would be a bad idea: say a malicious user creates a site that will fork ten-thousand repositories by force. That could make Github vulnerable to denial-of-service attacks.

How to add a wiki to a GitHub repo?

I have a private repo that's part of an organization on GitHub. I don't see the normal link to the repo's wiki that I've seen on many other repos. How do I get to it?
I did a little more digging and figured this out, decided I’d document it for the next person. The GitHub wiki is a setting that’s off by default. From the repo page select Settings on the right side, then in the Features section check Wikis.