Newbie Questions


I have just found this and I am enjoying the flexibility that it offers, the power that templates, space script and objects provide is awesome for someone that can do some light programming. I do have a few questions that might be lack of of knowledge, or possibly not understanding how it all works.

  • Is there an easy way to create a sub-page? When using silverbullet as a PWA there isn’t access to the nav bar so the only way to add a page would be to manually type out the full current path + new page name. I have added the following widget at the top of my pages to open up a sub page called New Page, but it feels like a bit of a hack (and I then need to rename the page to have it work):
[[{{}}/New Page]]
  • Is there a way to tag an entire table, or is it only individual rows? In some use cases that I have, I may have multiple tables on a single page, and I want to have a spacescript that reads data from only specific tables. My current understanding is that I need to tag each table row to make this happen? Similar for tasks, I understand that I can only tag each task individually, no way to tag by page structure?

  • Is there a way to access the current row within a table? As far as I can tell, you would need to create the whole table as a JSON object in a template and then use a map function or something. It would be great if I could put into a cell something like template ${{@row.qty * @row.cost}} to calculate the row total.

  • Is there a way to use template language within a query. For example if I have multiple tags on a page, and collect all the tasks that have any one of those tags, then using an #each to or together the different tags would be useful, but I cannot seem to make it work.
    Edit - This does actually work. i.e.:

task where page = '{{}}' and ({{#each @currentTag in @page.tags}}tags = '{{@currentTag}}' or {{/each}} false)

Quick question about “there isn’t access to the nav bar”, what do you mean by this? You do see the regular SilverBullet navigation bar right?

As to how to do this: I personally don’t regularly create sub-pages under the current page, but I do often create pages at the same level. To do this more efficiently, you can open the Page Picker and then hit space (also works on mobile), which will complete the path of the current page excluding the last path segment (so basically prepare you to create another page in the same folder).

What you can also do is create a Live Template Widgets:

Create a page somewhere (name doesn’t matter) with the following:

tags: template
  where: 'true'
{[Navigate: To Page|Create sub-page]("{{}}/new")}

This will put a button on top of every page automatically that when you click it goes to that same page name with /new attached to the end. Again, not perfect because you have to rename it afterwards but getting closer.

What do you mean with tables here? You mean like a markdown table or something else?

Oh wow, I’m surprised this works, but good, although a bit scary. What you can do in general is write a custom function that does something like this:

silverbullet.registerFunction({name: "hasTagOverlap"}, (obj1, obj2) => {
  if(!obj1.tags) {
    return false;
  for(const tag of obj1.tags) {
    if(obj2.tags && obj2.tags.includes(tag)) {
      return true;
  return false;

page where hasTagOverlap(., @page)

Thanks for the thoughts, your “New Subpage” button works a little better than how I had it do that is nice to see. Also, I hadn’t thought about using a space-script in the query, so that is something for me to store in my knowledgebank for future use.

You are correct, I was meaning a markdown table, if I create a markdown table then is there a way to make all the rows within that table have a tag. Paragraphs have connected tags and page tags attached, and tasks pick up page tags, but it seems like table rows only get tags from their specific row. It would be nice if rather than tagging each row, you could tag the whole table (I guess similar to how YAML Data is managed, where all the items get the same tag applied).

i.e. instead of the following:

|Item 1 #Table1|200|2|
|Item 2 #Table1|300|5|
|Item 3 #Table1|400|0|

I could instead do this:

|Item 1|200|2|
|Item 2|300|5|
|Item 3|400|0|

Looking through the notes it seems like YAML Data does this, so if this is important to me than possibly this is the best way to go.