Hi. I’ve created a site using the Netlify CMS and Gatsby. Everything is working great except I don’t see the “View Preview” link in the editor toolbar. I do, however, see a “View Live” link once the post is published. I’m using Git Gateway with a GitHub repo, using the editorial workflow and meet all of the other requirements for the preview links. I’ve read through the documentation countless times and there must be something I’m missing. Any help would be much appreciated.
Hi @rick215, can you share your config.yml
? The preview links should work without any special configurations when using the CMS, editorial workflow and hosting on Netlify.
The CMS looks at the editorial workflow entry PR latest commit status and looks for a status with the string “deploy” in the context
.
You can manually verify the commit statues using an API request to GitHub:
curl "https://api.github.com/repos/<owner>/<repo>/commits/<commit_sha>/status"
More information here:
Hi @erez, thanks for your reply and the additional information. Here is my config.yml
. If Netlify can push and merge PRs in my repo, it should be able to retrieve the commit statuses as well, correct? Just wondering if there’s an authentication issue somewhere…
backend:
name: git-gateway
use_graphql: true
branch: master # Branch to update (optional; defaults to master)
publish_mode: editorial_workflow
# This line should *not* be indented
media_folder: "static" # Media files will be stored in the repo under images/uploads
public_folder: "/"
collections:
- name: "blog" # Used in routes, e.g., /admin/collections/blog
label: "Blog" # Used in the UI
folder: "content/blog" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
preview_path: "{{slug}}"
identifier_field: blogTitle
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "blogLayout", widget: "hidden", default: "blog"}
- {label: "Publish Date", name: "blogDate", widget: "datetime"}
- {label: "Author", name: "blogAuthor", widget: "string", required: false}
- {label: "Title", name: "blogTitle", widget: "string"}
- {label: "Subtitle", name: "blogSubtitle", widget: "string", required: false}
- name: blogImage
label: Featured image
widget: object
required: false
fields:
- {name: src, label: Image, widget: image, required: false}
- {name: alt, label: Alt text, widget: string, required: false}
- {label: "Body", name: "body", widget: "markdown"}
- name: postCategory
label: Category
widget: select
multiple: false
options:
- blog
- in-the-news
- partner-blog
- press-release
- webinar
- name: "bio" # Used in routes, e.g., /admin/collections/blog
label: "Bios" # Used in the UI
folder: "content/bio" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
preview_path: "{{slug}}"
identifier_field: bioName
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "bioLayout", widget: "hidden", default: "bio"}
- {label: "Name", name: "bioName", widget: "string"}
- {label: "Job Title", name: "jobTitle", widget: "string"}
- name: bioImage
label: Bio Image
widget: object
required: true
fields:
- {name: src, label: Image, widget: image, required: true}
- {name: alt, label: Alt text, widget: string, required: true}
- {label: "Bio Statement (for Leadership)", name: "bioText", widget: "markdown", required: false}
- {label: "Why", name: "whyAnswer", widget: "markdown"}
- {label: "Column One", name: "columnOne", widget: "markdown"}
- {label: "Column Two", name: "columnTwo", widget: "markdown"}
- {label: "Column Three", name: "columnThree", widget: "markdown"}
- name: jobCategory
label: Job Category
widget: select
multiple: false
options:
- support-staff
- chief
- director
- manager
- board-member
- {label: "Publish Date", name: "bioDate", widget: "datetime"}```
Thanks for sharing @rick215 and sorry for missing your reply.
You’re right, it should have access to the commit statuses.
I’ve created a site with your config and they are working for me:
You can find the repo and branch here:
I’m using netlify-cms@2.10.47
and netlify-cms-app@2.12.11
.
To verify the CMS is able to retrieve the commit statuses can share your browser network traffic during a full reload when editing an editorial work flow entry?
You should see similar requests to:
Hi @erez - Thanks again for your reply. I’ve updated my netlify-cms-app
version based on what you used to test, but it doesn’t seem to have fixed the issue. Here is my network traffic after creating a new post.
Thanks for the additional information @rick215 that is very helpful.
As the statuses
array is empty this mean that either there is an issue with updating the commit status from the Netlify build or that it hasn’t been started/completed yet.
Can you verify that the relevant PR has a deploy running for it in Netlify? I will also be helpful to check if it has any status checks in GitHub.
Thanks again
Hi @erez - You were right, the PR did not start a Netlify deploy. Someone in dev-ops turned off the Deploy Setting that automatically builds deploy previews for PRs.
Really sorry to bother you with such a silly issue. Thanks for all your help. I really appreciate it.
No worries @rick215, I’m glad we were able to track down the issue and find the solution.
Is preview path for pages possible?
This one works
- name: 'work'
label: 'Works'
label_singular: 'Work'
folder: '_work'
preview_path: '/work/{{slug}}' // this works
.....
But this one doesn’t
collections:
- name: 'pages'
label: 'Pages'
files:
- name: 'photography'
label: 'Photography'
preview_path: '/photography/' // this doesn't work? base_url/photography/
Hi @Timothy preview_path
is only available at the collection level at the moment.
You can up vote our feature request:
so it gets more visibility.
Thanks I upvoted. Also isn’t there some kind of hack or something to accomplish this because I don’t notice questions or answers around this issue?
Hey @Timothy,
Not that I know of, and a search through this forum doesn’t turn up anything either. You may have better luck in https://netlifycms.slack.com/. The issue is also tagged good first issue
so maybe you want to take a shot at a PR?