-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please update the Github Pages deployment wiki #9753
Comments
where is the wiki pages? they are not working no more |
We've removed the Wiki pages as all instructions have been moved to the Next.js docs. |
Yeah, but there were some examples in Wiki that are not in the docs like redirecting within getInitialProps. |
and there are also links to the missing wiki pages |
@chemicalkosek Redirecting in |
Could you please point out the resources that need updated? |
"See the section in Next docs about deployment for more information." in https://github.com/zeit/next.js/blob/canary/packages/create-next-app/templates/default/README.md |
Well, how else would we redirect server-side? I saw your answer here #4931 (comment), so I assume we just should move the client-side redirect to useEffect but the usual server-side redirect should be held within getIntialProps with |
thanks for sharing @xixixao this (almost) works really well! My project is on
I have to use dynamic routing, which means I updated my component to use the Link as defined above, in a context like the following: const CategoryLink = ({ name }) => (
<Link href="/category/[name]" as={`/category/${name}`}>
<a>{name}</a>
</Link>
); [EDIT: updated to fix the prefetch error] unfortunately the custom Link component caused an error and wouldn't follow the link. The error I got was https://github.com/zeit/next.js/blob/master/errors/incompatible-href-as.md I updated the custom Link component as follows: import Link from 'next/link'
// Fixes links by prepending linkPrefix when in deployed on Github
const PrefixedLink = props => {
const href = `${process.env.linkPrefix}${props.href}`;
const as = props.as ? `${process.env.linkPrefix}${props.as}` : href;
return (
<Link
href={href}
as={as}
passHref={props.passHref || false}
prefetch={props.prefetch || false}>
{props.children}
</Link>
)
}
export default PrefixedLink this works fine: Links are followed correctly and navigation is ok, and also sets the default prefetch prop to false, which is useful for static exports.
|
It seems the deployment instructions for Github Pages were now completely removed, there's nothing in the NextJS docs site about it? |
Where did the instructions for Github Pages go! |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
This page: https://github.com/zeit/next.js/wiki/Deploying-a-Next.js-app-into-GitHub-Pages
Should include the following:
For all sites
Create
next.config.js
in your main folder with the following:This will prevent next from generating a new version of the site every time you run build. This is helpful since you'll likely be pushing
out
folder to your source gh-pages branch (see below).For Project Page Sites
Fix your links by adding the following component to
components/
:And replace all
import Link from 'next/link'
in your code withimport Link from 'next/link'
And use the following
next.config.js
:Don't forget to replace
your-repo-name
with the actual name of your Github repository.Pushing to GitHub Pages from a Subdirectory
In your next folder run something like:
To add the output folder and commit it. Then push it (from the root of your repo) to
gh-pages
branch:If your next folder isn't at the root of your repo, you might need to replace
out
with the path to theout
folder from the root of your repo (ienext-website/out
).See https://gist.github.com/cobyism/4730490 for more details.
The text was updated successfully, but these errors were encountered: