Gatsby: Articles all under `/blog` while still have homepage

Created on 19 May 2018  路  5Comments  路  Source: gatsbyjs/gatsby

Hi all,

I am trying to get this specific setup for my gatsby site. I want to have a landing page and a separate blog articles to be inside /blog folder or path. The closest example I found so far is this:
https://github.com/DSchau/gatsby-blog-starter-kit/issues/28

is this possible with Gatsby?

domain.com
homepage

domain.com/blog
blog

domain.com/blog/article-1
article

question or discussion

Most helpful comment

Contrary to the veeery long linked article with wrong info, this seems to be how to solve it (see basePath variable), exports.onCreateNode:

    createNodeField({
      name: `slug`,
      node,
      value: `/${basePath}${value}`,
    })

All 5 comments

Here's a tutorial on that if you'll be using markdown for your articles https://www.gatsbyjs.org/tutorial/part-seven/

Basically the idea is, on your gatsby-node.js, you'll be generating pages that has a path with /blog/ as the prefix + the slug of your article.

As mentioned by @daydream05 - this is covered in linked tutorial.

@daydream05 @pieh

I assume you refer to the basePath parameter?

This does NOT seem to work.

@axhamre Please provide more details - and ideally separate issue/question.

Contrary to the veeery long linked article with wrong info, this seems to be how to solve it (see basePath variable), exports.onCreateNode:

    createNodeField({
      name: `slug`,
      node,
      value: `/${basePath}${value}`,
    })
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments

signalwerk picture signalwerk  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

dustinhorton picture dustinhorton  路  3Comments