Continuing to learn the whole HUGO ecosystem here, I figured I would try a little testing of some things. What if I had a bunch of data in a simple .json or .toml or .yaml or whatever file and wanted to pull/fetch data from that file into one of my posts? I did have some data from the last post about Henry James’s use of certain words that we used to generate some of the graphs. A little bit of fiddling around on the HUGO Discourse site, which provides a mountain of posts yielded some rather simple little shortcodes to fetch and pull data from another file stored in the data folder of this HUGO website. (Two other short writeups were quite helpful as well: here and here and also here and in this short YouTube video from “Pragmatic Reviews”.)

Assuming we had a .toml file that looked like the following,

.toml datafile screenshot,

it’s pretty simple to get that data fetched and into a table here in this post, like this:

titleportentousportentouslyprodigiousprodigiouslytotal_word_count
1875_roderick_hudson622465278
1877_the_american140165838
1878_daisy_miller000010941
1878_the_europeans2010295972
1879_a_bundle_of_letters00006652
1879_confidence010036189
1880_washington_square000032005
1881_portrait_of_a_lady_vol_1000155850
1881_portrait_of_a_lady_vol_2201052144
1886_the_bostonians_vol_1011037200
1886_the_bostonians_vol_2101038126
1888_the_aspern_papers000016937
1888_the_lesson_of_the_master000012817
1891_the_pupil00108866
1892_the_real_thing_and_other_tales001233811
1895_the_altar_of_the_dead10006852
1896_the_figure_in_the_carpet00017427
1897_what_maisie_knew414144334
1898_in_the_cage214115643
1898_turn_of_the_screw309118430
1902_some_short_stories011018131
1902_wings_of_the_dove_vol_1214035262
1902_wings_of_the_dove_vol_2209145163
1903_the_ambassadors428277633
1903_the_beast_in_the_jungle10118198
1904_the_golden_bowl607189794
1908_the_jolly_corner11206737
1909_italian_hours4119165937
1916_notes_on_novelists4111465544

What’s nice about the solution provided by Zachary Wade Betz is that it’s quite easy to add data to the file that then gets fed into the table in the post. So, I haven’t looked at every single Henry James text—if there were more in the future, it would be easy enough to add those texts to a script and then let the computer take care of the rest, ultimately updating the table easily enough.

More to come, no doubt …