Use your own HTML page
Last updated
Last updated
Inside the views folder, create a new HTML file named views\hello.html
with the following contents:
Vibe.d is a stickler to proper indentation so follow the indentation rules for HTML tags. Sometimes, your editor saves tabs as spaces so make sure the spacing in the file is consistent, either all tabs or all spaces, or you will see mysterious errors when compiling. If you encounter that, click on the indentation setting at the bottom of VS Code. Click on 'Tab Size:'
And the drop-down indentation options will show at the top
Choose ‘Convert indentations to Spaces’ or ‘Convert indentations to Tabs’, whichever is your preference as long as you are consistent, then save the file again.
Next, edit source\app.d to make it display the hello.html page.
And delete the hello() function at the bottom as it is no longer called.
Stop the application if it is still running by pressing Ctrl-C in the terminal window (maybe twice).
Compile and run the project with dub.
This time around, you notice that the required libraries were no longer downloaded so the compilation is a bit faster. Refresh your browser and you should see the new message.
To stop the running app, press Ctrl-C (maybe twice).
As you have noticed, this is the conventional directory layout of a Vibe.d app:
\source - your D code should reside here
\views - the HTML or template pages stay here
\public - for other files such as CSS, scripts, images, videos, etc.