Issue: Preview button not showing when setting is defined #133

Closed
opened 2026-10-05 02:27:04 +02:00 by adam · 14 comments
Owner

I did set frontMatter.preview.host to http://localhost:1313. Tried restarting whole system, not only VS Code, but no change. Tried in 2 different OSs (Win, Linux - Ubuntu) still no change.

image

I have also added my content folder by right clicking -> add folder. So the dashboard is appearing correctly. Only this preview option is not.

image

Originally posted by @sid-r-singh in https://github.com/estruyf/vscode-front-matter/discussions/165#discussioncomment-1565018

I did set `frontMatter.preview.host` to `http://localhost:1313`. Tried restarting whole system, not only VS Code, but no change. Tried in 2 different OSs (Win, Linux - Ubuntu) still no change. ![image](https://user-images.githubusercontent.com/68782815/139573589-9ce0311a-c976-4b32-b74e-7b5d4fc55133.png) I have also added my content folder by right clicking -> add folder. So the dashboard is appearing correctly. Only this preview option is not. ![image](https://user-images.githubusercontent.com/68782815/139573664-0e1206d9-a755-439b-9ff1-c9bc52c34ab8.png) _Originally posted by @sid-r-singh in https://github.com/estruyf/vscode-front-matter/discussions/165#discussioncomment-1565018_ <!-- github-sync-id:1042051008 -->
adam closed this issue 2026-10-05 02:27:04 +02:00
Author
Owner

Oh, I just noticed, you should first open one of your pages. Once you opened a page, you should see the preview button show up.

Oh, I just noticed, you should first open one of your pages. Once you opened a page, you should see the preview button show up. <!-- github-comment-id:957326456 -->
Author
Owner

Just in case, I have added the button on the panel to its base view. Which means that it will show up once the setting is present. Currently available in the beta version of the extension.

Just in case, I have added the button on the panel to its base view. Which means that it will show up once the setting is present. Currently available in the beta version of the extension. <!-- github-comment-id:957333966 -->
Author
Owner

Oh, I just noticed, you should first open one of your pages. Once you opened a page, you should see the preview button show up.

I tried that already. Let me post a video of what I am doing. The video starts right from the time I open VS Code.

https://user-images.githubusercontent.com/68782815/139837509-d2c0557c-7901-4a96-98ab-5455f8f9de22.mp4

> Oh, I just noticed, you should first open one of your pages. Once you opened a page, you should see the preview button show up. I tried that already. Let me post a video of what I am doing. The video starts right from the time I open VS Code. https://user-images.githubusercontent.com/68782815/139837509-d2c0557c-7901-4a96-98ab-5455f8f9de22.mp4 <!-- github-comment-id:957344324 -->
Author
Owner

Just in case, I have added the button on the panel to its base view. Which means that it will show up once the setting is present. Currently available in the beta version of the extension.

How do I install the beta version ?

> Just in case, I have added the button on the panel to its base view. Which means that it will show up once the setting is present. Currently available in the beta version of the extension. How do I install the beta version ? <!-- github-comment-id:957350735 -->
Author
Owner

You can install it via the following steps: https://beta.frontmatter.codes/docs/getting-started#beta-version

You can install it via the following steps: https://beta.frontmatter.codes/docs/getting-started#beta-version <!-- github-comment-id:957368858 -->
Author
Owner

Oh 🤦‍♂️ - it the slug of your article, as there is none defined in your front matter of the content, it will not show the button. I'll implement the logic for this.

Oh 🤦‍♂️ - it the slug of your article, as there is none defined in your front matter of the content, it will not show the button. I'll implement the logic for this. <!-- github-comment-id:957393479 -->
Author
Owner

Logic has been implemented into the beta.

It will get the slug from the following things:

  1. Slug in the front matter
  2. The filename, if it's not index.md
  3. The folder name
Logic has been implemented into the beta. It will get the slug from the following things: 1. Slug in the front matter 2. The filename, if it's not `index.md` 3. The folder name <!-- github-comment-id:957494889 -->
Author
Owner

Wow that was quite fast! Preview button is appearing now but another small problem cropped up. All my markdown files are within content/blog folder. Accordingly, the preview URL should be http://localhost:1313/blog/slug. But the blog part is missing in the preview URL.

image
So, folder name is captured correctly. Only the registered folder name is missing.

You might wonder whether I have registered my blog folder or not. I have done it. The proof lies in my frontmatter.json, which is:

{
  "$schema": "https://frontmatter.codes/frontmatter.schema.json",
  "frontMatter.framework.id": "hugo",
  "frontMatter.content.publicFolder": "static",
  "frontMatter.content.pageFolders": [
    {
      "title": "blog",
      "path": "c:/Users/SIDHARTH R/Documents/blog-new/content/blog"
    }
  ]
}

Additional info: here is how my content is organized. If the URL in production is example.com/blog/slug then the corresponding .md file lives at \content\blog\slug\index.md.

Wow that was quite fast! Preview button is appearing now but another small problem cropped up. All my markdown files are within `content/blog` folder. Accordingly, the preview URL should be `http://localhost:1313/blog/slug`. But the `blog` part is missing in the preview URL. ![image](https://user-images.githubusercontent.com/68782815/139860453-ab300db1-2d54-4b76-b38d-540cd997abc3.png) So, folder name is captured correctly. Only the registered folder name is missing. You might wonder whether I have registered my `blog` folder or not. I have done it. The proof lies in my `frontmatter.json`, which is: ``` { "$schema": "https://frontmatter.codes/frontmatter.schema.json", "frontMatter.framework.id": "hugo", "frontMatter.content.publicFolder": "static", "frontMatter.content.pageFolders": [ { "title": "blog", "path": "c:/Users/SIDHARTH R/Documents/blog-new/content/blog" } ] } ``` **_Additional info:_** here is how my content is organized. If the URL in production is `example.com/blog/slug` then the corresponding `.md` file lives at `\content\blog\slug\index.md`. <!-- github-comment-id:957604599 -->
Author
Owner

You will need to specify one last thing, the preview pathname: https://frontmatter.codes/docs/settings#frontmatter.preview.pathname

So in your case, you'll need to add:

{
  "frontMatter.preview.pathName": "'blog/'"
}

As all SSGs and sites are different, this pathname setting is used for it. Now that there is the frontMatter.content.pageFolders setting, it can be good to extend it with a custom pathname as well.

You will need to specify one last thing, the preview pathname: https://frontmatter.codes/docs/settings#frontmatter.preview.pathname So in your case, you'll need to add: ``` { "frontMatter.preview.pathName": "'blog/'" } ``` As all SSGs and sites are different, this pathname setting is used for it. Now that there is the `frontMatter.content.pageFolders` setting, it can be good to extend it with a custom pathname as well. <!-- github-comment-id:957842640 -->
Author
Owner

That worked like a charm 🎉✨🤩. Thanks a lot for helping me out. I'm happy that I contributed to the project in some way 😄.

That worked like a charm 🎉✨🤩. Thanks a lot for helping me out. I'm happy that I contributed to the project in some way 😄. <!-- github-comment-id:957968807 -->
Author
Owner

Thank you @sid-r-singh! Already using the extension and providing feedback is a great contribution! 🙏

Thank you @sid-r-singh! Already using the extension and providing feedback is a great contribution! 🙏 <!-- github-comment-id:958771930 -->
Author
Owner

FYI: the preview path can now also be defined per content type: https://beta.frontmatter.codes/docs/content-types#preview-path

FYI: the preview path can now also be defined per content type: https://beta.frontmatter.codes/docs/content-types#preview-path <!-- github-comment-id:958924997 -->
Author
Owner

Thanks a ton for mentioning that. This is exactly what I was about to try out today. I was planning to add a content/snippets folder apart from the content/blog which I have now. In this case the URL needs to be http://localhost:1313/snippets/slug.

I was thinking whether it will be possible to achieve this or not & here you have already shipped this new feature. 🥳

Thanks a ton for mentioning that. This is exactly what I was about to try out today. I was planning to add a `content/snippets` folder apart from the `content/blog` which I have now. In this case the URL needs to be ` http://localhost:1313/snippets/slug`. I was thinking whether it will be possible to achieve this or not & here you have already shipped this new feature. 🥳 <!-- github-comment-id:958944441 -->
Author
Owner

@sid-r-singh this is now released in the main version.

@sid-r-singh this is now released in the main version. <!-- github-comment-id:961715331 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#133