How to host the some custom hbs file that is in my VPS? Like I have my /ghost/themes/casper directory hosted and now I want to manually add file and same hosted from this path also /ghost/themes/casper/releases/1100.hbs so my website should show website.com/releases/1100
Itβs not entirely clear what you are trying to achieve. However, to modify a theme, including the .hbs
files, you should edit the theme to customize as needed, then zip up the whole theme folder, and upload to Ghost.
I will try to be more clear. If this is my current structure
βββ /assets
| βββ /css
| βββ screen.css
| βββ /fonts
| βββ /images
| βββ /js
βββ default.hbs
βββ index.hbs
βββ post.hbs
βββ package.json
I want to make it like this
βββ /assets
| βββ /css
| βββ screen.css
| βββ /fonts
| βββ /images
| βββ /js
βββ /releases
| βββ /1100.hbs
| βββ /1101.hbs
| βββ /goeson.hbs
βββ default.hbs
βββ index.hbs
βββ post.hbs
βββ package.json
So my the page URL will become website.com/releases/1100, website.com/releases/1100 and goes on⦠But I am not sure how to make it work.
I still donβt understand what youβre trying to achieve since these folders are neither served nor accessible via a web browser.
Perhaps it would help if you explained the objective.
Like I want to serve my custom HTML code to my website in a folder inside the ghost hosting directory because I want the URL format to be like this website.com/releases/1100 so I have some certain webpages that will appear under the directory called as releases. Basically I am trying to get the proper URL for some of webpages.
Once again, I am trying to get this custom link format for my webpages under releases.
Custom HTML etc. is determined by the default theme. Therefore, make changes to the theme files, and let Ghost handle locations. More than one theme may be uploaded, so switching between themes is simple.
Your theme doesnβt really interact with URL formatting in Ghost; thatβs primarily handled by Dynamic Routing.
If you need custom HTML for your releases page, you probably want to use custom post templates and/or an HTML card.
Got it. Can you just help with giving an idea of how I can possibly write dynamic routing code for my situation?
I havenβt tested it, but something like this. Youβll need to tag all your release posts with #release
, and the slug should be the number (e.g. 1100
)
routes:
collections:
/:
permalink: /{slug}/
template: index
filter: -tag:hash-release
/releases/:
permalink: /releases/{slug}/
filter: tag:hash-release
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
Okay, I understood the format and went through the documentation also. But when I tried it only works with using posts because of which it is visible under an author. Our website wants no extra featuring like comments and visible under the author apart from the custom URL.
I can give the logic of our case, the URL - releases is based on pages for our teamβs every monthβs stats and updates and obviously it should not appear under any author nor have comments section for it. Like website.com/releases/0001 and goes on till around website.com/releases/0350
I would be thankful if you could guide with the format for custom link for pages option.
Iβm not entirely sure if you can prevent the post from appearing in the author list without messing up the post count. As a workaround, it is possible to create a new user (e.g. release-bot
) and attribute all the release posts to that author - it might not fix the author issue, but it would prevent other authorsβ page from getting messed up.
Regarding formatting - you can either update your existing post template to conditionally hide elements when rendering a release post, or you can use a custom post template.
Hereβs an example:
{{^has tag="hash-release"}}
{{comments}}
{{/has}}
This translates to βUnless the current item has the tag #release, load the commentsβ
Thank you, I will try it out.