Detect tag with 2d raycasting

So I am making a pokemon clone in unity.
For this project I need to know if you can walk somewhere. I don’t want to use box colliders since it looks buggy.

So I have got this so far:

        if (Input.GetKey(KeyCode.UpArrow) && isMoving == false)
        {
            bool disableMove = false;
            RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.up, 0.1F);

            if (hit != null)
            {
                if (hit.collider.gameObject.tag == "collision")
                {
                    disableMove = true;
                }
            }

            if (!disableMove)
            {
                increment = 0;
                isMoving = true;
                startPoint = transform.position;
                endPoint = new Vector2(transform.position.x, transform.position.y + 1);
            }
            disableMove = false;
        }

this gives me a Nullreference on

if (hit.collider.gameObject.tag == "collision")

I am not sure how to solve this.
what am I missing?

So i fixed it myself…

I stopped using a tag and made a new layer called it collision.
then I changed this:

RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.up, 0.1F);
 
            if (hit != null)
            {
                if (hit.collider.gameObject.tag == "collision")
                {
                    disableMove = true;
                }
            }

to this:

public LayerMask GroundLayer;


if (Physics2D.Raycast(transform.position, Vector2.up, 1, GroundLayer))
            {
                disableMove = true;
            }
            else
            {
                Debug.Log("nothing");
            }

just give your gameObject a layer select the layer on your script.
Then it will work!