You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've had a Gatsby site now for close to a year, and after updating the CLI and React today internal linking has been acting weird. I didn't change anything else and reviewed all dependencies, but the problem persists.
Essentially for my blog I have a tags page programmatically generated from markdown files with the appropriate information queried from GraphQL. Before the update I would click on a tag and a feed of posts under that tag would be displayed that when you click a post would route you to a URL like this: www.thisisasite.com/blog-post, but now if I click a post in the feed instead it tries to navigate to www.thisisasite.com/tags/tag/blog-post which results in a 404 error.
Normal site directory is set up with pages, templates, and styles all in separate folders underneath. The markdown posts are located in a folder under the pages folder.
When I query the slug I set up routing according to documentation with: , but it's still giving me the above error.
My inclination is that after the update the pre-rendering for paths with is bugging out and trying to create paths for posts on pages using the current directory or component as the root instead of the main domain.
Any help much appreciated or if y'all have seen anything like this happening since the update.
The text was updated successfully, but these errors were encountered:
caljup
changed the title
Link Routing for Tags and Previous/Next Buttons Not Working Properly
Internal Link Routing for Tags and Previous/Next Buttons Not Working Properly
Jul 3, 2020
We recently fixed a broken behavior: #24054
TL;DR: Link now also supports relative links.
Can you please share a reproduction of your problem, a link to your repo, or check whether your links all begin with a / or not? Because if not they are all relative.
Added in the linking with / and that fixed the problem. Since Link now supports relative links, links to internal pages from current route will treat the current directory as having a trailing slash, which was why www.thisisasite.com/blog-post would set the link to the next post as www.thisisasite.com/blog-post/blog-post 2.
Solutution was easy enough. If you have a link going to programatically generated slugs and you are passing 'slug' into the component code previously looked like this
<Link to = {slug}}>
{title}
</Link>
Just changed link to {/${slug}} and that fixed the issue
I've had a Gatsby site now for close to a year, and after updating the CLI and React today internal linking has been acting weird. I didn't change anything else and reviewed all dependencies, but the problem persists.
Essentially for my blog I have a tags page programmatically generated from markdown files with the appropriate information queried from GraphQL. Before the update I would click on a tag and a feed of posts under that tag would be displayed that when you click a post would route you to a URL like this: www.thisisasite.com/blog-post, but now if I click a post in the feed instead it tries to navigate to www.thisisasite.com/tags/tag/blog-post which results in a 404 error.
The same thing occurs on each post where I have a Next and Previous button to switch between posts. In that case if you hit Next instead of going to www.thisisasite.com/blog-post-2 it tries to navigate to www.thisisasite.com/blog-post-1/blog-post-2.
Normal site directory is set up with pages, templates, and styles all in separate folders underneath. The markdown posts are located in a folder under the pages folder.
When I query the slug I set up routing according to documentation with: , but it's still giving me the above error.
Under gatsby-node.js I have everything set up exactly based on the documentation here: https://www.gatsbyjs.org/docs/adding-tags-and-categories-to-blog-posts/
This is the code for creating each page:
}
Config file is set as:
My inclination is that after the update the pre-rendering for paths with is bugging out and trying to create paths for posts on pages using the current directory or component as the root instead of the main domain.
Any help much appreciated or if y'all have seen anything like this happening since the update.
The text was updated successfully, but these errors were encountered: