Joining variables while injecting frontmatter from csv

I have a set of data in _data/company.csv I’m trying to inject

{% if page.categories == "companies" %}
  {% assign name = %}
  {% assign sortedtags =[name].parent | join:[name].related | sort %}
{% else %}
  {% assign sortedtags = site.tags | sort %}
{% endif %}

but I got this error:

Liquid Exception: Liquid syntax error (line 6): Expected id but found open_square in "{{[name].parent | join:[name].related | sort }}" in /_layouts/tags.html

any help or suggestions would be appreciated

The problem is with[name]. Correct it with[name] instead.

1 Like

heyyyy great and so quick. thanks!

1 Like

ok… so now I’m super confused and nothing seems to be working.

I pared down my code and find that I’m not actually getting any result by this method

I clicked resolved before because my build error went away, but actually no results, yet

I have this on a page whos data is in that particular data file, and what I’m expecting here is for it to print the row of that spreadsheet bearing the name of that page.

{% assign name = %}

{{[name] }}

meanwhile I did verify that {{ }} actually gives the name of that page… what I can’t seem to manage is displaying any data from it.

I cleaned up my data in case of any interference from stray commas or extra double quotes that might be confusing to the interpreter…

only thing Im wondering now is if there can be some capitalization issue here. but after that I’m running out of attempts.

what I figured out is that the data file is consumed and stored as a hash. This will take some more thought, but I think I got this… just a little more loopage.

for the win:

{% assign name = %}
{% for company in %}
  {% if == name %}
    {{ company.parent }}    
    {{ company.related }}    
  {% endif %}
{% endfor %}