[英]How to make my gatsby link work properly in netlify?
I am trying to route between pages in gatsby.我正在尝试在 gatsby 中的页面之间进行路由。 It works in local host but sadly not in netlify.
它适用于本地主机,但遗憾的是不适用于 netlify。
The route link is My-site.com/about/ It doesn't work in netlify but when I reload the page the route become My-site.com/About/ and the page content shows.路由链接是 My-site.com/about/ 它在 netlify 中不起作用,但是当我重新加载页面时,路由变为 My-site.com/About/ 并且页面内容显示。
In my index.js在我的 index.js 中
function Home = () => {
return (
<Link to="/about/"> About Page </Link>
);
};
export default Home;
In About.js在 About.js 中
function About = () => {
return (
<h2> This is About page </h2>
);
};
export default About
Your About.js
file should be named about.js
(lowercased).您的
About.js
文件应命名为about.js
(小写)。 This is because with Gatsby, components under src/pages
become pages automatically with paths based on their filename.这是因为在 Gatsby 中,
src/pages
下的组件会根据文件名自动变为带有路径的页面。
You can check Pages and Layout documentation for further information.您可以查看页面和布局文档以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.