question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blog recipe posts in root URL

See original GitHub issue

We’re migrating our blog to WYAM. For SEO reasons we’d like to keep our posts in root URL (not in /posts/ subfolder). For example /my-article-1 instead of /posts/my-article-1.

I know we can use redirects (using metadata RedirectFrom:), but it is not enough for us. We need the final (redirected) URL to stay in root.

When setting BlogKeys.PostsPath to /, an error “Rooted globbing patterns are not supported” occurs. When setting BlogKeys.PostsPath to empty string, an error “Access to the path ‘c:\index.html’ is denied.” occurs (because WYAM is trying to overwrite index of homepage with index of archive page).

Is there any way how to do it properly?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jansotolacommented, Apr 17, 2020

I’ve managed to do renaming of the “Archive” page web folder by rewriting BlogArchive pipeline. It may be a dirty and brute force solution but it works:

int archiveIndex = Pipelines.IndexOf("BlogArchive");
Pipelines.Remove("BlogArchive");
Pipelines.Insert(archiveIndex, "BlogArchive",
  // most of the lines have been copied from WYAM Blog.cs
  new Wyam.Web.Pipelines.ConditionalPipeline(
    ctx => ctx.Bool(BlogKeys.GenerateArchive),
    new Wyam.Web.Pipelines.Archive(
      "BlogArchive",
      new Wyam.Web.Pipelines.ArchiveSettings
      {
        Pipelines = new string[] { "BlogPosts" },
        TemplateFile = ctx => "_Archive.cshtml",
        Layout = "/_Layout.cshtml",
        PageSize = ctx => ctx.Get(BlogKeys.ArchivePageSize, int.MaxValue),
        Title = (doc, ctx) => "Archive",
        // the only redefined line
        RelativePath = (doc, ctx) => $"{ctx.DirectoryPath(BlogKeys.PostsPath, ".").FullPath.Replace(ctx.String(BlogKeys.PostsPath), "archive")}"
      })));
qqq
0reactions
daveaglickcommented, Apr 23, 2020

Great, glad you found a solution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

I built a site that gets you a recipe from a URL without all of ...
Very nice, I will save this for recipes :) I'd rather have a website get big enough to be able to ask people...
Read more >
Sharing Sites for Food Bloggers (2023)
Here are all the important sharing sites for food bloggers where you can share your photos and recipes to get more traffic!
Read more >
Why Food Bloggers Don't "Just Post the Recipe"
Food bloggers get a lot of hate for not "just posting the recipe" and instead writing long stories with lots of photos in...
Read more >
Our Favorite Food Sharing Sites (2022)
Do you submit your blog recipes to food sharing sites? These recipe aggregator sites help recipe creators by amplifying their content to new ......
Read more >
Recipe Attribution
Wondering how to properly attribute a recipe for publication? Some tips and suggestions from cookbook author David Lebovitz.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found