an image

What's next?

I followed a tutorial to get my blog up and running. But I wouldn't say I absorbed every step of what I was doing. So now it's time to start making tweaks and changes. Along the way I suspect I'll get a better handle on actix_web, tera, and the rest of the dependencies in my Cargo.toml file:

[dependencies]
actix-files = "0.6.2"
actix-web = "4"
env_logger = "0.10.0"
ignore = "0.4.20"
lazy_static = "1.4.0"
log = "0.4.18"
pulldown-cmark = { version = "0.9.3", default-features = false }
serde = { version="1.0", features=["derive"] }
serde_json = "1.0.96"
tera = "1"
toml = "0.7.4"

Moving the blog from the homepage to /blog

This was a simple change. I just used a method of actix_web called web::scope:

And then I changed some hard-coded urls in my html templates:


Move blog to /blog

3 files changed, 6 insertions(+), 4 deletions(-)
blog/src/main.rs         | 6 ++++--
blog/templates/home.html | 2 +-
blog/templates/post.html | 2 +-

modified   blog/src/main.rs
@@ -28,13 +28,15 @@ async fn main() -> std::io::Result<()> {
     log::info!("starting HTTP server at http://localhost:8080");

     HttpServer::new(|| {
+        let blog = web::scope("/blog")
+            .service(handlers::index)
+            .service(handlers::post);
         App::new()
             .app_data(web::Data::new(TEMPLATES.clone()))
             .wrap(middleware::Logger::default())
             .service(Files::new("/static", "static/").use_last_modified(true))
             .route("/health", web::get().to(HttpResponse::Ok))
-            .service(handlers::index)
-            .service(handlers::post)
+            .service(blog)
     })
     .bind(("127.0.0.1", 8080))?
     .run()
modified   blog/templates/home.html
@@ -6,7 +6,7 @@
     <h1 class="text-center text-3xl">John Shaughnessy</h1>
     <h3 class="text-center text-lg mt-2 text-gray-600">My blog.</h3>
     {% for fm in posts %}
-    <a class="mb-3" href="/posts/{{fm.file_name}}">
+    <a class="mb-3" href="/blog/posts/{{fm.file_name}}">
         <div class="flex flex-col mb-5 px-4 py-6 cursor-pointer">
             <h2 class="text-2xl font-semibold hover:underline">{{fm.title}}</h2>
             <div class="flex items-center mt-2">
modified   blog/templates/post.html
@@ -4,7 +4,7 @@

 {% block header %}
 <div class="relative mt-2 ml-4 flex w-full justify-center">
-    <a class="absolute left-0 underline" href="/">Go back</a>
+    <a class="absolute left-0 underline" href="/blog/">Go back</a>
     <p class="hidden md:inline text-lg">{{ meta_data.title }}</p>
 </div>
 {% endblock header %}

Making a new homepage

Moving the blog means that I've made room for a new landing page. I like personal websites that have simple landing pages whose primary responsibility is to link out to whatever other websites might be important for that person.

On my homepage, I'd like to have:

Professional info:

Personal info:

I think for now that's enough. Later, if I create a twitter account or whatever else then I'll include it.

I'd also like to include a hidden auth capability that will let me access some pages that I'll use for myself. For example there's often random data points that I want to keep track of and I'd like to be able to insert them into a database through my website because it'll be easy to do that from my phone from wherever I am.

Making development more pleasant

I want to avoid having to manually stop and restart my server whenever a file changes. It takes almost no time to build, so I'd prefer to have it automatically rebuild/restart while I'm developing.

To do this, I'll use cargo-watch:

cargo watch -x run